美文网首页
iOS返回到指定页面的两种方法

iOS返回到指定页面的两种方法

作者: Hither | 来源:发表于2017-05-22 17:07 被阅读582次

在开发中 经常会有这样的需求,要求app 在完成某些操作以后 返回到某一界面 ,下面是我常用到的两种方法;

//方法一: 返回到制定界面  但不是根界面的某个界面
UserSettingViewController *homeVC = [[UserSettingViewController alloc] init];
        UIViewController *target = nil;
        for (UIViewController * controller in self.navigationController.viewControllers) { 
            if ([controller isKindOfClass:[homeVC class]]) { 
                target = controller;
            }
        }
        if (target) {
            [self.navigationController popToViewController:target animated:YES]; 
        }
方法二:返回到根界面上的某个界面
self.navigationController.tabBarController.hidesBottomBarWhenPushed=NO;
    self.navigationController.tabBarController.selectedIndex=0;
    [self.navigationController popToRootViewControllerAnimated:YES];

相关文章

网友评论

      本文标题:iOS返回到指定页面的两种方法

      本文链接:https://www.haomeiwen.com/subject/dxhixxtx.html