How to disable the phone to slide back to the previous page. Swiping back to the previous page was a great user experience. But in a special scene to slide back to the previous page seriously affect the user experience: 1. Such as fighting landlord, as a result of the card, due to the left of the card, accidentally triggered the slide away from the dou Landlord page. Do you think it’s boring? Even more outrageous is that some apps, this douzhu is random. After you leave again want to enter continue in the original dou Landlord, the result found that there is no dou landlord entrance. The result has to be managed by the system. Do you think it’s boring? So such a page shake is not allowed to slide back to the previous page, but to return to the previous page by clicking on the left hand side. 2. In the login page, due to the side slip, you will return to the original page without logging in, and various errors will appear. So the landing page should also be set to slide back to the previous page. Normal pages only need this setting to prevent the slide back to the previous page.

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    // Turn on the return gesture
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.navigationController.interactivePopGestureRecognizer.enabled = NO; }} - (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    // Turn on the return gesture
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.navigationController.interactivePopGestureRecognizer.enabled = YES; }}Copy the code

The problem is that the page so set is invalid and still set. Then we’ll have to do something tough. Find the popup gesture time, disable it, and set to release it when you leave.

  • (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated];

    [self.playerView startPlaying]; [self popGestureChange:self enable:NO];

/ / / / open return gestures / / if ([self. The navigationController respondsToSelector: @ the selector (interactivePopGestureRecognizer)]) {/ / self.navigationController.interactivePopGestureRecognizer.delegate = self; // } } -(void)popGestureChange:(UIViewController *)vc enable:(BOOL)enable{

If ([vc navigationController respondsToSelector: @ the selector (interactivePopGestureRecognizer)]) {/ / to iterate through all the hand gestures for (UIGestureRecognizer *popGesture in vc.navigationController.interactivePopGestureRecognizer.view.gestureRecognizers) { popGesture.enabled = enable; }}Copy the code

}

  • (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [self.playerView pausePlaying]; [self popGestureChange:self enable:YES];

/ / / / open return gestures / / if ([self. The navigationController respondsToSelector: @ the selector (interactivePopGestureRecognizer)]) {/ / self.navigationController.interactivePopGestureRecognizer.delegate = nil; // } self.navigationController.navigationBar.hidden = NO; }

Copy the code