ModalViewController 仅在动画时显示

Posted

技术标签:

【中文标题】ModalViewController 仅在动画时显示【英文标题】:ModalViewController only displays if animated 【发布时间】:2011-06-30 14:56:31 【问题描述】:

在我的应用委托中,我想为应用首次启动显示一个注册屏幕。

这是我的代码:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
self.window.rootViewController = self.tabBarController;
[[[self.tabBarController.tabBar items] objectAtIndex:2] setEnabled:NO];    
[[[self.tabBarController.tabBar items] objectAtIndex:3] setEnabled:NO]; 

if (![self checkAuth]) 
    SignupViewController * signUp = [[SignupViewController alloc] initWithNibName:@"SignupView" bundle:nil] ;
    [signUp setManagedObjectContext:self.managedObjectContext];
    [[self tabBarController] presentModalViewController:signUp animated:YES] ;
    [signUp release] ;

[self.window makeKeyAndVisible];
return YES;

一切正常,但我不希望我的 modalViewController 被动画化......

当我换行时:

[[self tabBarController] presentModalViewController:signUp animated:YES] ;

为:

[[self tabBarController] presentModalViewController:signUp animated:NO] ;

我的底层 tabBarController 显示了,我的 modalViewController 没有出现!

我花了很多时间搜索有类似问题的人,但我没有找到任何解决方案......

有人可以帮助我吗?

【问题讨论】:

【参考方案1】:

尝试在 presentModalViewController 之前调用[self.window makeKeyAndVisible];

【讨论】:

我想在动画==YES 的情况下,在显示 modalView 时会有一点延迟,这会使窗口在真正添加 modalView 之前可见。如果 animated==NO modalView 将被添加而窗口不可见并被忽略。

以上是关于ModalViewController 仅在动画时显示的主要内容,如果未能解决你的问题,请参考以下文章