加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

iPhone – 解雇RootViewController?

发布时间:2020-12-14 17:15:46 所属栏目:百科 来源:网络整理
导读:我有一个RegistrationViewController和一个LoginViewController: LoginViewController是我的InitialViewController / RootViewController. 如果我注册并单击Registrate-Button,它将自动推送到MainViewController.如果我按下Logout-Button,它会关闭到Registr
我有一个RegistrationViewController和一个LoginViewController:

LoginViewController是我的InitialViewController / RootViewController.

如果我注册并单击Registrate-Button,它将自动推送到MainViewController.如果我按下Logout-Button,它会关闭到RegistrationViewController,这是因为我使用[self dismissModalViewController animated:YES].

- (IBAction)logoutPressed:(id)sender {
  [self dismissModalViewControllerAnimated:YES];
   }

如果我按下Logout-Button,我如何解除对LoginViewController的关注.

解决方法

您可以使用UINavigationController方法-popToRootViewControllerAnimated:.

- (IBAction)logoutPressed:(id)sender {
    [self.navigationController popToRootViewControllerAnimated:YES];
}

如果您正在谈论一个在另一个上面呈现的几个模态视图,您可以通过将-dismissViewControllerAnimated:completion:或者old -dismissModalViewControllerAnimated:发送到堆栈中的最低层来解除所有这些视图,如文档中所述:

If you present several view controllers in succession,thus building a stack of presented view controllers,calling this method on a view controller lower in the stack dismisses its immediate child view controller and all view controllers above that child on the stack. When this happens,only the top-most view is dismissed in an animated fashion

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读