InteractivePopGestureRecognizer causing app freezi

2019-03-09 20:58发布

In my app I have different controllers. When I push controller1 to navigation controller and swipe to back, all works good. But, if I push navigation controller1, and into controller1 push controller2 and try to swipe to back I get a frozen application. If go back through back button all works fine.

How can I catch the problem?

8条回答
我只想做你的唯一
2楼-- · 2019-03-09 21:35

My solution is exchange self.navigationController.interactivePopGestureRecognizer.delegate between selfImplementDelegate and SystemDelegate

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [_tableView reloadData];
    _oldReturnDelegate = self.navigationController.interactivePopGestureRecognizer.delegate;
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
}

- (void)viewWillDisappear:(BOOL)animated
{
    self.navigationController.interactivePopGestureRecognizer.delegate = _oldReturnDelegate;
    [super viewWillDisappear:animated];
}
查看更多
Anthone
3楼-- · 2019-03-09 21:41

Swift 4

Add this code to root navigation controller

func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
    return self == self.navigationController?.topViewController ? false : true
}

Add UIGestureRecognizerDelegate protocol

self.navigationController?.interactivePopGestureRecognizer?.delegate = self
self.navigationController?.interactivePopGestureRecognizer?.isEnabled = true
查看更多
登录 后发表回答