我在我的应用程序的 appdelegate 中。如何在“didfinishlaunching”方法中添加模式视图控制器?
我尝试了以下方法但没有成功
SomeViewController *vc = [[SomeViewController alloc]init];
[self.tabController.navigationController presentModalViewController:vc animated:NO];
编辑:
我将我的实现更改为以下内容
self.tabController.selectedViewController
= [self.tabController.viewControllers objectAtIndex:0];
SomeViewController *vc = [[SomeViewController alloc]init];
[self.tabController.selectedViewController presentModalViewController:vc animated:NO];
我检查了“选定的视图控制器”不为空...但是我仍然无法获得所需的输出。我有什么遗漏的吗?
假设 tabController 和 navigationController 不为 nil,则 applicationDidFinishLaunching 可能太快而无法显示模式视图控制器。
- 确保在使窗口成为关键且可见之后放置该代码。
[self.window makeKeyAndVisible];
- 如果这不起作用,请尝试聆听
UIWindowDidBecomeKeyNotification
对于那个窗口
- 您可以尝试使用以下命令延迟该模式的呈现几秒钟执行选择器:withObject:延迟后: http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/Reference/Reference.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)