2017-08-24 91 views
0

後的空白視圖休息一年後返回到iOS開發,並且它的所有混亂。pushViewController

當執行下面的3行代碼時,我看到下面的模擬器的屏幕截圖。

我也試圖添加LoginForm視圖控制器作爲根視圖控制器,因爲它應該,除了我也看到一個空白的屏幕。

如xcode屏幕截圖所示,命名全部匹配。所有的限制也是藍色的。

我已經在LoginForm的viewDidLoad中包含了一個NSLog,我已經看到了日誌點,但是仍然沒有顯示。

我在想什麼,或者做錯了什麼?我沒有任何錯誤可以與之合作。

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 
UIViewController *view = [storyboard instantiateViewControllerWithIdentifier:@"LoginForm"]; 
[self.navigationController pushViewController:view animated:YES ]; 

enter image description here enter image description here

+0

是自我在首位navigationcontroller? – koropok

+0

不,自己是從第一個ViewController內部被調用的 –

+0

從你的屏幕截圖看起來像你沒有嵌入導航控制器 –

回答

2

嘗試使用

[self presentViewController:myVC animated:NO completion:nil]; 

因爲你的故事板似乎不使用導航控制器上。

+0

謝謝,這個工程。儘管@Piyush Patel對導航控制器做了一個很好的評論,但我覺得我也可能遇到與此相關的問題。無論如何,你的答案是:) –

0

如果你有XIB文件

Viewcontroller1 *viewController = [[Viewcontroller1 alloc] 
    initWithNibName:@"Viewcontroller1" bundle:nil]; 
    [[self navigationController] pushViewController:viewController animated:YES]; 

,如果你有故事板

Viewcontroller1*vc=[self.storyboard instantiateViewControllerWithIdentifier:@"Viewcontroller1"]; 
[self.navigationController pushViewController:vc animated:YES];