简体   繁体   English

从UITabBarController呈现模式视图

[英]Presenting a modal view from a UITabBarController

I checked the various answers here and could not find one which works. 我在这里检查了各种答案,但找不到合适的答案。 I have a regular TabBarController based application. 我有一个基于TabBarController的常规应用程序。 I want to show a login screen at launch. 我想在启动时显示登录屏幕。 What I did was 我所做的是

  • Subclassed UITabBarController and implemented the following in the viewDidAppear: 子类化UITabBarController,并在viewDidAppear中实现了以下内容:

    LoginViewController *controller = (LoginViewController *)[[UIStoryboard storyboardWithName:@"Main" bundle: nil] instantiateViewControllerWithIdentifier:@"LoginVC"]; LoginViewController * controller =(LoginViewController *)[[UIStoryboard storyboardWithName:@“ Main”捆绑包:无] InstantiateViewControllerWithIdentifier:@“ LoginVC”]; [self presentViewController:controller animated:YES completion:nil]; [自身presentViewController:controller动画:是完成:无];

Once this runs there are 2 things happening : 1. The login view never shows up 2. The log has this : Warning: Attempt to present on whose view is not in the window hierarchy! 一旦运行,将发生两件事:1.登录视图从不显示。2.日志显示以下内容:警告:尝试显示不在窗口层次结构中的视图!

What am I missing? 我想念什么?

rdelmar answer fixed the warning, that is do the presentation in the viewDidAppear. rdelmar回答修复了警告,即在viewDidAppear中进行演示。 Thanks! 谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM