I have added 'interactivePopGestureRecognizer' in some viewcontroller, also give back button on topbar . When user use Pop Gesture and push/pop view at that time it will freez top navigation controller view . After some time it will crash with "[viewcontroller hash]: message sent to deallocated instance."
METHOD
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
//Pop GESTURE
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled = true;
self.navigationController.interactivePopGestureRecognizer.delegate = self;
}
-(void)viewDidDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
//Remove Pop Gesture
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled = false;
self.navigationController.interactivePopGestureRecognizer.delegate = nil;
}
}
DELEGATE METHOD
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
// add whatever logic you would otherwise have
return YES;
}
I have TabBar type application.
The crash would be explained by you somehow failing to execute
in
viewDidDisappear
. Can you confirm that your delegate is actually being removed by stepping through it in the debugger?