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

第一种情况:

从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页面。解决方法如下:

  • 在B页面present到C页面的时候,B页面先present到C页面,然后B页面再pop到A页面(这种情况下把animation设置成false,否则会有一个一闪而过的动画,体验不是太好)。
PayViewController *payVC = Storyboard(@"Main", @"PayViewController");
UINavigationController *navigatoinController = [[UINavigationController alloc] initWithRootViewController:payVC];
[self presentViewController:navigatoinController animated:true completion:nil];
[self.navigationController popViewControllerAnimated:false];
  • 在C页面push到D页面的时候,先获取到present之前的navigationController,用这个navigationControllerpush到D页面,然后再将C页面dismiss
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];
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • { 11、核心动画 需要签协议,但是系统帮签好 一、CABasicAnimation 1、创建基础动画对象 CAB...
    CYC666阅读 1,704评论 2 4
  • 这是我写于2015年12月24日的一则随笔。 今天是平安夜,水果店里用漂亮的心形纸盒包装一个大苹果,微信群里转发G...
    小时君阅读 367评论 0 1
  • 曾记 诗酒正年华 感伤不过是一场无端而至的秋凉 我陷入沉醉 又疑惑迷惘 离别 不用诉离殇 眼泪不过是一杯天涯各两端...
    秋山纱兰阅读 251评论 0 1
  • 1、在手机OA主界面,点击“云办文”,进入办文界面。 2、在进入办文界面后,点击下方文件列表,即可查看相关文件的内容。
    维他柠檬茶哈阅读 299评论 0 0
  • 第十八章 李晚晴在猫又旅馆住的甚是惬意,早上跟林秋一起跑跑步,之后就列出长长的菜单,让林秋照做,大半个月过去,整个...
    宋家娘子阅读 335评论 2 2

友情链接更多精彩内容