Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New gesture - Swipe left to right - as shortcut for Back button in UINavigationController in old app

iOS 7 sports a new gesture, swiping left to right across the screen as a shortcut for the Back button in a UINavigationController.

My app does not seem to be picking up this behavior for free. What do I need to do to make this gesture available to my iOS app (built for iOS 5.1 and later in Xcode 4.6.3)?

Here's an article with video, The new gesture in iOS 7 you want to know about, from a user's perspective.

The answer may have something to do with interactivePopGestureRecognizer which is a UIGestureRecognizer subclass.

like image 389
Basil Bourque Avatar asked Oct 21 '22 23:10

Basil Bourque


1 Answers

It should work automatically if the back button is visible. If you are displaying a leftBarButtonItem instead of the back button, the gesture will not be present by default. Also, if you are using a UINavigationBar but not a UINavigationController, you won't see this functionality.

If you are using a UINavigationController and your view controller's navigation item contains a leftBarButtonItem, it's still possible to add functionality for the swipe left to right gesture of the navigation controller, by attaching a delegate to the navigation controller's interactivePopGestureRecognizer.

EDIT: I didn't notice that you're building against SDK 5.1. This is a new feature in the iOS 7 SDK, so I believe you'll need to build with Xcode 5 against the iOS 7 SDK in order to make use of the new feature.

like image 53
Greg Avatar answered Nov 09 '22 14:11

Greg