2017-05-02 61 views
1

我已經創建了一個視圖控制器通過新文件,我檢查了創建筆尖選項,並沒有問題。我做了一個很好的IB佈局,事情很好。文件所有者被鏈接到正確的ViewController,nib中的視圖鏈接到文件所有者的視圖插座。試圖用.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. 
} 
+0

你可以發佈在applicationDidFinishLaunching中調用的整個代碼嗎? – user3797599

+0

我已經這麼做:) – jbehrens94

+0

我沒有看到任何地方[self.window makeKeyAndVisible]; – user3797599

回答

2

呼叫[self.window makeKeyAndVisible];在applicationDidFinishLaunching

相關問題