问题描述
所以我有一个UITabBarController应用程序,我想显示一个登录页面,所以我做了:
So I have a UITabBarController app and I want to display a login page, and so I did:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(userDidLogin:) name:UserDidLoginNotification object:nil];
LoginViewController* loginViewController = [[LoginViewController alloc] init];
self.tabBarController.selectedViewController = [self.tabBarController.viewControllers objectAtIndex:0];
[self.tabBarController.selectedViewController presentModalViewController:loginViewController animated:NO];
[loginViewController release];
在我的LoginViewController中我还可以显示另一个modalViewController:
Inside my LoginViewController I can as well show another modalViewController:
- (void) twitterLogin: (UIViewController *) askingView
{
UIViewController *controller = [SA_OAuthTwitterController controllerToEnterCredentialsWithTwitterEngine: _twitter delegate: self];
if (controller) {
self.askingView = askingView;
[askingView presentModalViewController: controller animated: YES];
}
}
我有以下方法,其中askView是LoginViewController ,
,当我想解雇我时:
I have the following method where the askingView is the LoginViewController,when I want to dismiss this I do:
[self.askingView dismissModalViewControllerAnimated:YES];
[[NSNotificationCenter defaultCenter] postNotificationName:UserDidLoginNotification object:nil];
然而,这并没有解除LoginViewController并显示UITabBarController视图..它只是取消了我的modalViewController从LoginvVIewController中显示。我在这做错了什么?我也收到以下错误:
However, this doesn't dismiss the LoginViewController and show the UITabBarController views.. it just dismisses my modalViewController shown from the LoginvVIewController. What am I doing wrong here? I am also getting the following error:
attempt to dismiss modal view controller whose view does not currently appear. self = <LoginViewController: 0x2aff70> modalViewController = <SA_OAuthTwitterController: 0x2d2a80>
2011-09-16 09:45:37.750 VoteBooth[4614:707] attempt to dismiss modal view controller whose view does not currently appear. self = <MainViewController: 0x29fec0> modalViewController = <LoginViewController: 0x2aff70>
推荐答案
为了解除显示的模态视图另一个模态视图,您必须在父项的父项上调用 dismissModalViewControllerAnimated:
。我已经在我的一些应用程序中使用了它,它对我来说非常漂亮(经过多次艰苦的努力试图解决它)。这正是我用过的:
In order to dismiss a modal view that is presented over another modal view, you have to call dismissModalViewControllerAnimated:
on the parent of the parent. I have used this in some of my apps and it has worked beautifully for me (after many painstaking hours trying to figure it out). Here is exactly what I've used:
[[[self parentViewController] parentViewController] dismissModalViewControllerAnimated:YES];
这篇关于解雇modalViewController的modalViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!