2012-11-24 73 views
0

可能重複:
whose view is not in the window hierarchy問題與視圖控制器

我有我的代碼有問題。

我想去另一個視圖控制器,所以這裏是我的代碼:

- (void)reloadMyTB { 
     TestViewController *vc = [[TestViewController alloc] init]; 
     UINavigationController *cntrol = [[UINavigationController alloc] initWithRootViewController:vc]; 
     [self presentModalViewController:cntrol animated:NO]; 
     [cntrol release]; 
} 

但它一點兒也不工作,我可以讀取日誌中的以下行:

Warning: Attempt to present <UINavigationController: 0x133db4b0> on <ArticleViewController: 0x13828330> whose view is not in the window hierarchy! 

謝謝!

+0

@Abizern我們添加了相同的鏈接。 – sunkehappy

+0

@sunkehappy當我將問題標記爲重複項時,除系統添加了我的項目外。最好標記/標記重複項,而不是留下一條消息,因爲這樣可以更好地集中網站,並且,如果問題被關閉,它將自動鏈接到重複項。 – Abizern

+0

是的,但我不想把我的代碼放在viewDidLoad或viewDidAppear – userFromGluiras

回答

1

先檢查有你在你的應用程序中實現導航控制器,如果沒有然後實現它第一次然後繼續爲波紋管

並結合景觀與文件的所有者

請重寫代碼爲波紋管

TestViewController *vc = [[TestViewController alloc] initWithNibName:@"TestViewController" bundle:nil]; //or write TestViewController nib Name here 
    UINavigationController *cntrol = [[UINavigationController alloc] initWithRootViewController:vc]; 
    [self presentModalViewController:cntrol animated:NO]; 
    [cntrol release]; 
+0

我已經實現了導航控制器。我重寫了代碼,但沒有任何反應。 – userFromGluiras