IOS app all add swipe back

Source: Internet
Author: User

if ([self class] = = [Homeviewcontroller class]| | [Self class] = = [Comprehensivefinanceviewcontroller class]| | [Self class] = = [Mycenterviewcontroller class]| | [Self class] = = [Customermanageviewcontroller class]) {

Add left sweep and right sweep gestures

Uiswipegesturerecognizer *swipeleft = [[Uiswipegesturerecognizer alloc] initwithtarget:self action: @selector ( Tappedrightbutton:)];

[Swipeleft Setdirection:uiswipegesturerecognizerdirectionleft];

[Self.view Addgesturerecognizer:swipeleft];

Uiswipegesturerecognizer *swiperight = [[Uiswipegesturerecognizer alloc] initwithtarget:self action: @selector ( Tappedleftbutton:)];

[Swiperight Setdirection:uiswipegesturerecognizerdirectionright];

[Self.view Addgesturerecognizer:swiperight];

Write to master controller and swipe gesture listener in base class controller

-(Ibaction) Tappedrightbutton: (ID) sender

{

Nsuinteger SelectedIndex = [Self.tabbarcontroller selectedindex];

Nsarray *aryviewcontroller = self.tabBarController.viewControllers;

if (SelectedIndex < aryviewcontroller.count-1) {

UIView *fromview = [Self.tabBarController.selectedViewController view];

//

UIView *toview = [[Self.tabBarController.viewControllers objectatindex:selectedindex + 1] view];

//

[UIView transitionfromview:fromview Toview:toview duration:0.5f options:uiviewanimationoptiontransitionflipfromr Ight completion:^ (BOOL finished) {

//

if (finished) {

[Self.tabbarcontroller Setselectedindex:selectedindex + 1];

//            }

//

//        }];

}

}

-(Ibaction) Tappedleftbutton: (ID) sender

{

Nsuinteger SelectedIndex = [Self.tabbarcontroller selectedindex];

if (SelectedIndex > 0) {

UIView *fromview = [Self.tabBarController.selectedViewController view];

//

UIView *toview = [[Self.tabBarController.viewControllers objectatindex:selectedindex-1] view];

[UIView transitionfromview:fromview Toview:toview duration:0.5f options:uiviewanimationoptiontransitionflipfroml EFT completion:^ (BOOL finished) {

//

if (finished) {

[Self.tabbarcontroller setselectedindex:selectedindex-1];

//            }

//

//        }];

}

}

This allows the global slide to return

If the Web controller implements the sliding return function, it must be implemented in Wkwebview

_wkwebview.allowsbackforwardnavigationgestures = yes;//Open webview page slide back

}else{

Self.navigationController.interactivePopGestureRecognizer.delegate = (id) self;

}

It's so simple.

IOS app all add swipe back

Related Article

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.