IOS 7 uses Uiscreenedgepangesturerecognizer to achieve swipe to pop effects

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.