iOS View controller left edge right slide pop out stack
After IOS7.0, Apple optimized a small function, that is, for the Uinavagationcontroller stack of Uiviewcontroller, as long as the left edge of the view controller to the right slide, the view controller will pop out of the stack (if for the non-root view controller, of course). The implementation of the method is very simple, one sentence to fix:
self.navigationController.interactivePopGestureRecognizer.enabled = YES;
In fact, for a view controller, the default value for this property is yes, so it is not set and can also implement the function of right-slide pop. However, this feature is very limited because it does not allow the current view controller to customize the Leftbarbuttonitem, and once customized, the right slide function becomes invalid. Here's one way:
Self.navigationController.interactivePopGestureRecognizer.delegate = nil;
After you set the proxy to nil, you can right-swipe pop even after customizing the Leftbarbuttonitem.
In fact, if you customize the Leftbarbuttonitem, the usual practice is to reset the proxy:
-(void) Viewdidappear: (BOOL) Animated{__weak typeof (self) weakself = self; Self.navigationController.interactivePopGestureRecognizer.delegate = weakself;}
The gesture protocol can then be implemented:
#pragma mark-uigesturerecognizerdelegate-(BOOL) Gesturerecognizershouldbegin: (uigesturerecognizer*) gesturerecognizer{ //Determine if Rootviewcontroller if (Self.navigationcontroller && Self.navigationController.viewControllers.count = = 1) { return NO; } return YES;}
iOS development-View controller left edge right slide pop out stack