2011-04-21 80 views
0

我試圖使用pushViewController:動畫:有一個UIViewController。我使用initWithRoot將它安置在UINavigationController中,但它仍然不起作用。使用pushViewController:動畫:

這裏是我的代碼?難道我做錯了什麼?

CloudappSettingsViewController *cloud = [[CloudappSettingsViewController alloc] initWithNibName:nil bundle:nil]; 
     UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:cloud]; 
     [self pushViewController:nav animated:YES]; 
     [cloud release]; 

它總是崩潰時,得到最多的[self pushViewController:nav animated:YES];

任何想法? 感謝

回答

0

是 「自我」 一個UINavigationController?

似乎您試圖推導航控制器,但是這是倒退。您應該出示導航控制器並將其他視圖推送給它。

所以UIView的你在應該已經在導航控制器,那麼你將推動雲成說。

0

如果這是你的應用程序委託,只需添加的UINavigationController作爲一個子視圖到你的應用程序的窗口。如果你想呈現的UINavigationController作爲一個模式視圖控制器然後做到這一點:

[self presentModalViewController:nav animated:YES]; 
+0

它不在我的AppDelegate中。它在我的ViewController中。我正在尋找實現設置的推動和流行動畫。我有一個想法讓它工作。現在讓我給出一個鏡頭。 **編輯**設置SettingsViewController作爲UINavigationController沒有工作 – Frankrockz 2011-04-21 14:55:00

0

,因爲你設置的筆尖,以零它肯定會崩潰。

CloudappSettingsViewController *cloud = [[CloudappSettingsViewController alloc] initWithNibName:@"NibName goes here" bundle:nil]; 

創建一個筆尖並將其分配給您的視圖控制器。

+0

我今天早上嘗試過。它甚至可以在UIViewController上使用pushViewController和popViewController嗎? – Frankrockz 2011-04-21 17:35:21

+0

是的,這絕對有可能。在他們的視圖控制器中,你總是可以像這樣做,並推動和彈出:[self.navigationController pushViewController:newViewController animated:YES];或者做類似的事情來彈出。我只是注意到你的代碼中,你只是在調用SELF來推動它,我猜它會導致崩潰。 – 2011-04-22 00:10:06

相關問題