LoginViewController是我的InitialViewController / RootViewController.
如果我注册并单击Registrate-Button,它将自动推送到MainViewController.如果我按下logout-Button,它会关闭到RegistrationViewController,这是因为我使用[self dismissModalViewController animated:YES].
- (IBAction)logoutPressed:(id)sender { [self dismissModalViewControllerAnimated:YES]; }
如果我按下logout-Button,我如何解除对LoginViewController的关注.
解决方法
- (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