【发布时间】:2025-12-13 10:45:02
【问题描述】:
我已经在网络和 Stack Overflow 上搜索了几个小时,但我无法解决这个问题。这里希望你们都看到我的错误,因为我找不到它。
我刚刚启动了一个基于故事板的简单应用程序。初始 ViewController 是 UITabBarController 的一个实例,其中包含模板中的两个虚拟 ViewController。启动时,我需要检查设备是否登录到外部服务。如果没有,我将显示一个允许用户进行身份验证的模态 ViewController,如果设备通过了身份验证,那么我将只显示 FirstViewController。
以下步骤是我创建项目后所做的一切:
- 在 Storyboard 上创建 AuthenticateViewController 场景
- 为AuthenticateViewController创建代码文件,并分配给对应的场景
- 为 UITabBarController 子类创建代码文件,并将初始 UITabBarController 场景与该新子类相关联
- 在情节提要上创建一个从 UITabBarController 场景到 AuthenticateViewController 场景的新转场
- 从 UITabBarController 子类中的
viewDidLoad手动调用 segue
当我运行应用程序时,模态序列没有触发,UITabBarController 的第一个 ViewController 显示出来,我在 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
【问题讨论】:
标签: ios ios5 ios6 uistoryboard uistoryboardsegue