iOS: fix non ui thread access view content offset

This commit is contained in:
王劲鹏 2023-07-20 17:14:51 +08:00 committed by osborn
parent 01b30f48bb
commit 761a6f67a4
4 changed files with 28 additions and 24 deletions

View File

@ -565,15 +565,16 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (!self.jsDispatcher) {
self.jsDispatcher = [DoricJSDispatcher new];
}
NSDictionary *offset = @{
@"x": @(self.view.contentOffset.x),
@"y": @(self.view.contentOffset.y),
};
__weak typeof(self) __self = self;
[self.jsDispatcher dispatch:^DoricAsyncResult * {
__strong typeof(__self) self = __self;
return [self callJSResponse:self.onScrollFuncId,
@{
@"x": @(self.view.contentOffset.x),
@"y": @(self.view.contentOffset.y),
},
nil];
return [self callJSResponse:self.onScrollFuncId, offset, nil];
}];
}
}

View File

@ -471,15 +471,16 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (!self.jsDispatcher) {
self.jsDispatcher = [DoricJSDispatcher new];
}
NSDictionary *offset = @{
@"x": @(self.view.contentOffset.x),
@"y": @(self.view.contentOffset.y),
};
__weak typeof(self) __self = self;
[self.jsDispatcher dispatch:^DoricAsyncResult * {
__strong typeof(__self) self = __self;
return [self callJSResponse:self.onScrollFuncId,
@{
@"x": @(self.view.contentOffset.x),
@"y": @(self.view.contentOffset.y),
},
nil];
return [self callJSResponse:self.onScrollFuncId, offset, nil];
}];
}
}

View File

@ -587,15 +587,16 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (!self.jsDispatcher) {
self.jsDispatcher = [DoricJSDispatcher new];
}
NSDictionary *offset = @{
@"x": @(self.view.contentOffset.x),
@"y": @(self.view.contentOffset.y),
};
__weak typeof(self) __self = self;
[self.jsDispatcher dispatch:^DoricAsyncResult * {
__strong typeof(__self) self = __self;
return [self callJSResponse:self.onScrollFuncId,
@{
@"x": @(self.view.contentOffset.x),
@"y": @(self.view.contentOffset.y),
},
nil];
return [self callJSResponse:self.onScrollFuncId, offset, nil];
}];
}
}

View File

@ -136,15 +136,16 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (!self.jsDispatcher) {
self.jsDispatcher = [DoricJSDispatcher new];
}
NSDictionary *offset = @{
@"x": @(self.view.contentOffset.x),
@"y": @(self.view.contentOffset.y),
};
__weak typeof(self) __self = self;
[self.jsDispatcher dispatch:^DoricAsyncResult * {
__strong typeof(__self) self = __self;
return [self callJSResponse:self.onScrollFuncId,
@{
@"x": @(self.view.contentOffset.x),
@"y": @(self.view.contentOffset.y),
},
nil];
return [self callJSResponse:self.onScrollFuncId, offset, nil];
}];
}
}