【发布时间】:2017-05-02 13:58:21
【问题描述】:
我已经通过新文件创建了一个视图控制器,我检查了创建 nib 选项,一切正常。我做了一个很好的 IB 布局,一切都很棒。文件所有者链接到正确的 ViewController,nib 中的视图链接到文件所有者中的视图出口。
现在,我尝试用 AppDelegate 中的 nib 实例化这个视图控制器。
TerminationViewController *terminatedVC = [[TerminationViewController alloc] initWithNibName:@"TerminationViewController" bundle:nil];
terminatedVC.view.hidden = NO;
[self.window.rootViewController presentViewController:terminatedVC animated:YES completion:nil];
没有错误,我看到黑屏。我究竟做错了什么?我还检查了笔尖的目标成员资格。
编辑
self.window = [[[InterceptorWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
self.window.backgroundColor = [UIColor whiteColor];
TerminationViewController *terminatedVC = [[TerminationViewController alloc] initWithNibName:@"TerminationViewController" bundle:nil];
terminatedVC.view.hidden = NO;
[self.window.rootViewController presentViewController:terminatedVC animated:YES completion:nil];
// Wait for 10 seconds
double delayInSeconds = 10.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void) {
// Do something, next view controller.
}
【问题讨论】:
-
你能发布在 applicationDidFinishLaunching 中调用的整个代码吗?
-
我已经这样做了:)
-
我看不到任何地方 [self.window makeKeyAndVisible];
-
发生在dispatch_after的block中,我应该先做吗?
-
当然 ;) 做到了 ;)
标签: ios objective-c interface-builder xib nib