最近发现一个问题,在首页有一些操作是要跳转到一个新页面 bVC,但是看到状态栏左上方的小菊花也转圈了,就是页面不跳转,卡住不动了,或者导航栏更新成了bVC,但是 view 没变化。按下 home 键回到桌面,再次点击启动 app,页面显示的是本该跳转的新页面,显然跳转了,但是 UI 没有刷新。再次操作还是一样的效果,双击 home 键划掉 app才恢复正常。很郁闷,不知道怎么回事。在首页如上操作后(应该跳转至新页面,但其实 UI 卡住),,使用左滑手势从右面划出来一部分本该跳转的那个新页面,但不能完全划出(本来应该什么都划不出来的,因为首页就是最上面的 VC),我就猜想有可能是左滑手势的问题。我发现在 BaseVC类调用了
self.navigationController.interactivePopGestureRecognizer.delegate = self;
也就是说当前navgationController的每个页面都有左滑手势,包括viewController[0],就是这里的问题,当时没注意。左滑手势是为了pop 回上个页面,所以位于当前navgationController的第一个([0])viewController时需要设置手势代理,不响应。
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
这句一定要放在viewDidAppear而不是viewWillAppear里
- (void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
if(self.navigationController){
if([self.navigationController.viewControllers[0] isEqual:self]) {
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}
}
}
- (void)viewDidDisappear:(BOOL)animated{
[super viewDidDisappear:animated];
if(self.navigationController){
if([self.navigationController.viewControllers[0] isEqual:self]) {
self.navigationController.interactivePopGestureRecognizer.enabled = YES;
}
}
}