我一直在搜索网络和堆栈溢出几个小时,我无法解决这个问题。希望你们都能看到我的错误,因为我找不到它。手动模态segue不起作用,View Controller不在窗口层次结构中?
我有一个简单的基于故事板的应用程序,我刚开始。最初的ViewController是UITabBarController的一个实例,其中包含模板中的两个虚拟ViewController。启动后,我需要检查设备是否登录到外部服务。如果没有,我会显示一个模式ViewController,它将允许用户进行身份验证,如果设备已通过身份验证,那么我将只显示FirstViewController。
下面的步骤是一切,因为在创建项目我做:
- 在故事板
- 创建AuthenticateViewController场景创建AuthenticateViewController代码文件,并将它们分配到相应的场景
- 创建用于UITabBarController子类的代码文件,并将初始UITabBarController场景关联到该新子类
- 在故事板上从UITabBarController场景创建一个新的Segue到Authenti cateViewController现场
- 手动从
viewDidLoad
中的UITabBarController的子类调用SEGUE
当我运行模式SEGUE不火的应用,显示了的UITabBarController的第一个视图控制器,我得到在Xcode中下面的输出:
Warning: Attempt to present <AuthenticateViewController: 0x83c0c10> on <EPTabBarController: 0x83be600> whose view is not in the window hierarchy!
下面的相关代码,实际上是我迄今为止添加的唯一代码。请让我知道截图或其他信息是否有用。在此先感谢您的帮助。
EPTabBarController,的UITabBarController的子类:
#import "EPTabBarController.h"
#import "AuthenticateViewController.h"
@interface EPTabBarController()
@end
@implementation EPTabBarController
- (void)viewDidLoad
{
[super viewDidLoad];
[self performSegueWithIdentifier:@"authenticationSegue" sender:self];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
这样的工作,但我觉得这是一个相当不雅的解决方案。这是完成这个的唯一方法吗? “执行SegueWithIdentifer:”呼叫应该放在其他地方吗? – blundin 2013-03-25 15:42:31
嘿@blundin请尝试设置afterDelay:0.0并检查。让我知道如果作品顺利 – 2013-03-25 15:44:53
是的,这工作顺利。谢谢。 – blundin 2013-03-27 02:18:27