"Reprint Please specify the source"
In IOS 7, in addition to the traditional upper-left return key, a gesture that returns to the top-level interface is provided with a right slide. This gesture is supported by the new attribute in Uinavigationcontroller
Interactivepopgesturerecognizer, that is, right-sliding returns only supports switching between Viewcontroller with Uinavigationcontroller as a container and requires some extra work to be used in a custom container.
Basically, control whether the Viewcontroller is enabled for right-sliding return, only this is necessary:
. navigationController.interactivePopGestureRecognizer.enabled =;
By default, enabled is yes.
In the actual use, encountered a number of problems, organized as follows:
1. After the custom return button, the right slide returns to fail;
Solution: The more intuitive approach is to use Backbarbuttonitem when customizing the return button:
UIButton *backbutton = Uibarbuttonitem *baritem =. Navigationitem.backbarbuttonitem = Baritem;
P.S: The difference between Backbarbuttonitem and Leftbarbuttonitem:
http://www.cocoachina.com/ask/questions/show/97110
However, this does not support the case of multiple buttons in the upper left corner. Consider that Interactivepopgesturerecognizer also has the delegate attribute, which replaces the default self. Navigationcontroller. Interactivepopgesturerecognizer.delegate to configure the performance of the right slide return is also feasible. In the main viewcontroller:
. Navigationcontroller.interactivepopgesturerecognizer. = ;
-(BOOL) Gesturerecognizershouldbegin: (Uigesturerecognizer * (. NavigationController.viewControllers.count = =) }
The advantage of this is that you can configure all Viewcontroller in the stack in the main viewcontroller to be turned back on, without having to set enabled separately in each viewcontroller.
It is worth noting that after replacing the delegate, you must set a Viewcontroller a in Gesturerecognizershouldbegin: To turn the right slide back, The interactivepopgesturerecognizer.enabled = no is not set at the same time, and the right-slip return is turned on, that is, any of the two is no and the right-slip return is off.
2, the main interface (the first viewcontroller in the Uinavigationcontroller stack) is also turned on by default to return to the right slide. If you are sliding right on the main interface, no action will be taken. But when you want to go to the next level Viewcontroller (such as clicking a line in TableView), the toggle animation does not appear. Cut back to the desktop and then into the application, found directly into the next level Viewcontroller.
Solution: This problem occurs when you initially test the use of the right-side return. In a viewcontroller that uses the custom return button
. Navigationcontroller.interactivepopgesturerecognizer. = ;
Resolves problem 1 while causing problem 2. Similar to 1, after replacing the default delegate, Interactivepopgesturerecognizer can invoke the custom return method. The specific reason is unclear, pending the update of "Mark".
3. When you use the right slide back to drag halfway, you will sometimes see three small blue dots lined up on the navigation bar.
Solution: The cause is unclear and the solution is unclear.
P.S: See a method on a post:
Self.navigationItem.title =;
Can hide the small blue dot, but because the small blue point is not necessary, in the unclear situation is difficult to say whether it is effective.
Posts Link: http://www.tuicool.com/articles/FB3IJ3
(1) View in the project, self. Navigationcontroller. Interactivepopgesturerecognizer.delegate is actually a
_uinavigationinteractivetransition instances, which are declared as follows:
1; 2 3 {4 *_; 5} 6 7; 8 9-() _;10-() _; 11-(); 12-(); 13-(); 14-(); 15-(); 16-(); 17-(); 18-(); 19-(); 20 2 1
As you can see, the inside of the delegate, which is actually a uiscreenedgepangesturerecognizer instance in action, is a new class introduced in IOS7 that supports the initialization of switching between viewcontroller in some cases. There are few descriptions of them in Apple's official documentation, as follows:
A UIScreenEdgePanGestureRecognizer
looks for panning (dragging) gestures this start near an edge of the. The system uses screen edge gestures in some cases to initiate view controller transitions. You can use this class to replicate the same gesture behavior for your own actions.
After creating a screens edge pan gesture recognizer, assign an appropriate value to the property edges
before attaching T He gesture recognizer to your view. Specify from which edges, the gesture may start. This gesture recognizer ignores any touches beyond the first touch.
To support a right-slip return in a custom Viewcontroller container, you might need to use it.
(2) Many applications still use the iOS 6.1 SDK, and a lot of iOS7 users have a very urgent need for right-sliding return, so it is necessary to simulate right-sliding return in iOS 6.1SDK in a short time. Here is a way to achieve the background of uiimage as the next level Viewcontroller by intercepting the parent Viewcontroller interface at push:
The author's intention does not seem to want to simulate right-slip return, but slightly modified can be used in a relatively simple structure, the following is the link:
Https://github.com/vinqon/MultiLayerNavigation
P.S: For some special needs, such as the ScrollView interface (such as browsing photos) to simulate the right slide back, when sliding to the far left when the right slide to return, the class is not satisfied, pending "Mark."
1, Uiscreenedgepangesturerecognizer Class Reference
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIScreenEdgePanGestureRecognizer_class/ Reference/reference.html#//apple_ref/occ/cl/uiscreenedgepangesturerecognizer
2, _uinavigationinteractivetransition.h
Https://github.com/nst/iOS-Runtime-Headers/blob/master/Frameworks/UIKit.framework/_UINavigationInteractiveTransition.h
3. When customizing the return button, the iOS7 gesture returns problems encountered
Http://www.tuicool.com/articles/FB3IJ3
Http://www.tuicool.com/articles/vMfAVv
Right slide back to iOS