When iOS 7 is not yet released, various apps implement various swipe to pop effects, such as.
On iOS 7, as long as it is a system-compliant navigation structure: [That is, the root view is controlled by the navigation controller]
Created by Wangyuanyuan on 14-9-15.//Copyright (c) 2014 ___fullusername___. All rights reserved.//#import "AppDelegate.h" #import "FirstViewController.h" #import "SecondViewController.h" @ Implementation appdelegate-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: ( Nsdictionary *) launchoptions{Self.window = [[UIWindow alloc] initwithframe:[[uiscreen mainscreen] bounds]]; Override point for customization after application launch. Self.window.backgroundColor = [Uicolor Whitecolor]; Firstviewcontroller * FIRSTVC = [[Firstviewcontroller alloc]init]; Secondviewcontroller * SECONDVC = [[Secondviewcontroller alloc]init]; Nsarray * arr = [Nsarray ARRAYWITHOBJECTS:FIRSTVC,SECONDVC, Nil]; Uitabbarcontroller * TABVC = [[Uitabbarcontroller alloc]init]; Tabvc.viewcontrollers = arr; Uinavigationcontroller * MAINVC = [[Uinavigationcontroller ALLOC]INITWITHROOTVIEWCONTROLLER:TABVC]; Self.window.rootViewController = MAINVC [Self.window makekeyandvisible]; return YES;}
will be able to have the original beautiful effect:
Unfortunately, the current project code does not follow the navigation structure of the iOS system, making it impossible to exploit this benefit. So I'm thinking about using the new Uiscreenedgepangesturerecognizer gesture:
1- (void) Viewwillappear: (BOOL) Animated2 {3 if(System_version_greater_than_or_equal_to (@"7.0")) {4Uiscreenedgepangesturerecognizer *left2rightswipe =[[Uiscreenedgepangesturerecognizer alloc]5 initwithtarget:self6 Action: @selector (handleswipegesture:)];7 [Left2rightswipe setdelegate:self];8 [Left2rightswipe Setedges:uirectedgeleft];9 [Self.view addgesturerecognizer:left2rightswipe];Ten } One A } - - the- (void) Handleswipegesture: (Uiscreenedgepangesturerecognizer *) Gesturerecognizer - { - [Self.navigationcontroller Popviewcontrolleranimated:yes]; -}
This also implements the effect of the relevant return function, in particular, related to gesture-related interference problems, see blog: http://blog.csdn.net/jasonblog/article/details/16867587
IOS 7 uses Uiscreenedgepangesturerecognizer to achieve swipe to pop effects