iphone - 谁的 View 不在窗口层次结构中!问题

标签 iphone ios uistoryboard segue

我的项目首先使用 UITabBarController 作为第一个出现的 View 创建,然后我需要添加一个显示 3 秒的自定义启动画面,所以我使用了一个出现在 UITabBarController 之前的新 UIViewController 并且我设置了这个自定义启动画面作为第一个出现的 View 。但是,在我做了那个改变之后。目前我的初始屏幕转到 UITabBarController,我收到了这个错误。

警告:尝试在 SplashViewController 上呈现 UITabBarController:0x1cdcfe30:0x1cdc55e0 其 View 不在窗口层次结构中!

我以这种方式在我的 SplashViewController 中执行 View 更改:

#import "SplashViewController.h"

@interface SplashViewController ()

@end

@implementation SplashViewController



- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    timer = [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(changeView) userInfo:nil repeats:YES];

}

-(void)changeView{

    [self performSegueWithIdentifier:@"splash" sender:self];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

顺便说一句,我正在使用 Storyboard,这是一个奇怪的错误,在我添加启动画面后一直出现在控制台中,我不知道如何摆脱它。

最佳答案

在身份检查器( Storyboard)中为 TabBarController 提供 Storyboard ID“TabBarViewController”

并实现 changeView 为-

-(void)changeView
{
    UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    TabBarViewController *tabBarViewController = [storyBoard instantiateViewControllerWithIdentifier:@"TabBarViewController"];
    [[[[UIApplication sharedApplication] delegate] window] setRootViewController:tabBarViewController];
}

关于iphone - 谁的 View 不在窗口层次结构中!问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14380680/

相关文章:

用于管理推送通知的 iOS API

objective-c - UISearchDisplayController 的搜索结果具有与搜索表不同的单元格布局和行为

iphone - 组合 NSMutableSets 时出现问题

ios - 如何使用GCM实现对iOS的可靠投递?

iphone - 如何将 HTML 代码更改为符号 iphone

ios - UIButton setSelected:否不显示默认背景图像

ios - IB 可设计 : Failed to render and update auto layout status for Google Maps

ios - 动态 TableView 单元格高度在滚动之前不正确(iOS 8)-附上完整的屏幕截图

iphone - iOS 4.2 上有哪些字体可用?

JQuery Mobile 100% 高度页面,等于可见区域