【发布时间】:2020-01-27 22:33:28
【问题描述】:
我将RNFrostedSidebar 用于左侧菜单。关闭侧边栏时,正在执行下面的代码块
- (void)handleTap:(UIPanGestureRecognizer *)recognizer {
[self dismissAnimated:YES completion:nil];
}
- (void)dismissAnimated:(BOOL)animated completion:(void (^)(BOOL finished))completion {
void (^completionBlock)(BOOL) = ^(BOOL finished){
[self rn_removeFromParentViewControllerCallingAppearanceMethods:YES];
rn_frostedMenu = nil;
if (completion) {
completion(finished);
}
};
if (animated) {
CGFloat parentWidth = self.view.bounds.size.width;
CGRect contentFrame = self.contentView.frame;
contentFrame.origin.x = self.showFromRight ? parentWidth : -_width;
CGRect blurFrame = self.blurView.frame;
blurFrame.origin.x = self.showFromRight ? parentWidth : 0;
blurFrame.size.width = 0;
self.blurView.frame = blurFrame;
self.blurView.alpha=0.1;
[UIView animateWithDuration:self.animationDuration delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
self.viewForTable.frame = contentFrame;
}
completion:completionBlock];
} else {
completionBlock(YES);
}
}
dismissAnimated 方法执行后,我想运行一个代码来更新 HomeViewController,该代码是
[self callNavBar];
-(void) callNavBar {
[[NSNotificationCenter defaultCenter] postNotificationName:@"adjustNavBar"
object:self];
}
我尝试了this 解决方案,比如在队列中添加方法并执行,但我得到了异常
“主线程检查器:在后台线程上调用的 UI API:-[UIView bounds]”
然后我尝试this too得到了和上面一样的错误。
【问题讨论】:
-
可以显示错误日志吗?
-
@trungduc 哪个错误日志,用于第一个解决方案还是第二个解决方案?
-
两个都显示就更好了
-
@trungduc 更新了问题,我在两种解决方案中都遇到了同样的错误。
标签: ios objective-c callback grand-central-dispatch objective-c-blocks