Objective C:如何从 appdelegate 呈现模态视图控制器?
我在我的应用程序的 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];
我检查了“选定的视图控制器”不为空...但是我仍然无法获得所需的输出。我有什么遗漏的吗?
I am in the appdelegate of my application. How can I add a modal view controller in the "didfinishlaunching" method?
I tried the following but did not work
SomeViewController *vc = [[SomeViewController alloc]init];
[self.tabController.navigationController presentModalViewController:vc animated:NO];
EDIT:
I changed my implementation to the following
self.tabController.selectedViewController
= [self.tabController.viewControllers objectAtIndex:0];
SomeViewController *vc = [[SomeViewController alloc]init];
[self.tabController.selectedViewController presentModalViewController:vc animated:NO];
I checked that the 'selected view controller' is not null... however I am still not able to get the output I needed. Is there anything I am missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设 tabController 和 navigationController 不为 nil,则 applicationDidFinishLaunching 可能太快而无法显示模式视图控制器。
[self.window makeKeyAndVisible];
UIWindowDidBecomeKeyNotification
Assuming tabController and navigationController are not nil, the applicationDidFinishLaunching may be too soon to display the modal view controller.
[self.window makeKeyAndVisible];
UIWindowDidBecomeKeyNotification
for that window