iOS软件开发

手势返回功能的一些页面处理

2016-05-29  本文已影响352人  Minoz_min

第一种情况:

从A页面push到B页面,B页面再push到C页面,其中B页面只是一个过渡页,在C页面返回的时候直接返回到A页面。解决方法如下:

- (void)pushCategoryDetailViewController
{
    CategoryDetailViewController *categoryDetailVC = Storyboard(@"Main", @"CategoryDetailViewController");
    [self.navigationController pushViewController:categoryDetailVC animated:YES];
    
    //手势返回里直接返回到上一个页面,例如A push B,B push C的时候把B移除,在C页面手势直接返回到A
    NSMutableArray *mArray = [NSMutableArray arrayWithArray:self.navigationController.viewControllers];
    if (self.navigationController.viewControllers.count > 1) {
        [mArray removeObject:self];
    }
    self.navigationController.viewControllers = mArray;
}

第二种情况:

从A页面push到B页面,B页面present到C页面,C页面再push到D页面,在D页面手势返回到A页面。解决方法如下:

PayViewController *payVC = Storyboard(@"Main", @"PayViewController");
UINavigationController *navigatoinController = [[UINavigationController alloc] initWithRootViewController:payVC];
[self presentViewController:navigatoinController animated:true completion:nil];
[self.navigationController popViewControllerAnimated:false];
OrderStatusTableViewController *orderStatusVC = Storyboard(@"Main", @"OrderStatusTableViewController");
orderStatusVC.hidesBottomBarWhenPushed = true;
UINavigationController *navigation = [[AppDelegate sharedAppDelegate].tabbarController selectedViewController];
[navigation pushViewController:orderStatusVC animated:YES];
[self dismissViewControllerAnimated:false completion:nil];

番外篇

UIScreenEdgePanGestureRecognizer *screenEdge = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(onScreenEdge)];
screenEdge.edges = UIRectEdgeLeft; [self.navigationController.interactivePopGestureRecognizer requireGestureRecognizerToFail:screenEdge];
[self.view addGestureRecognizer:screenEdge];
上一篇下一篇

猜你喜欢

热点阅读