iOS Navigation full screen swipe

Source: Internet
Author: User

Full-screen Slide code implementation

12345678910111213141516171819202122232425 - (void)viewDidLoad {    [superviewDidLoad];    // 获取系统自带滑动手势的target对象    id target = self.interactivePopGestureRecognizer.delegate;    // 创建全屏滑动手势,调用系统自带滑动手势的target的action方法    UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:target action:@selector(handleNavigationTransition:)];    // 设置手势代理,拦截手势触发    pan.delegate = self;    // 给导航控制器的view添加全屏滑动手势    [self.view addGestureRecognizer:pan];    // 禁止使用系统自带的滑动手势    self.interactivePopGestureRecognizer.enabled = NO;}// 什么时候调用:每次触发手势之前都会询问下代理,是否触发。// 作用:拦截手势触发- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{    // 注意:只有非根控制器才有滑动返回功能,根控制器没有。    // 判断导航控制器是否只有一个子控制器,如果只有一个子控制器,肯定是根控制器    if (self.childViewControllers.count == 1) {        // 表示用户在根控制器界面,就不需要触发滑动手势,        returnNO;    }    returnYES;}

iOS Navigation full screen swipe

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.