2011-07-19 40 views
1

我正在使用iPhone應用程序。我有下面的代碼跳到ProfileViewController(從HomeViewController):presentModalViewController iPhone

ProfileViewController *ProfilePage = [[ProfileViewController alloc] initWithNibName:@"ProfileViewController" bundle:nil]; 
ProfilePage.RequestType = 2; 
ProfilePage.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 

UINavigationController *navigationControllerNew = [[UINavigationController alloc] initWithRootViewController:ProfilePage]; 

//Present navigationController as Model viw controller 
[self.navigationController presentModalViewController:navigationControllerNew animated:YES]; 

//release it After presenting to it 
[navigationControllerNew release]; 
[ProfilePage release]; 

其工作正常,但是當我點擊ProfileViewController的「最後的視圖」按鈕後,回到同一個頁面,它再次但之後回來回來了。後退按鈕上的我的popToViewController在HomeScreenController上不起作用。可能是因爲堆疊中有新的導航控制器。

我在哪裏犯錯?如何實現再次使用「後退」按鈕?

回答

1

你不需要使用popToViewController什麼的。使用dismissModalViewControllerAnimated:回到主視圖的方法。

+0

謝謝,非常感謝您的幫助。它的工作現在很好。 –

+0

不客氣。 – Ilanchezhian

2

你不需要

UINavigationController *navigationControllerNew = [[UINavigationController alloc] initWithRootViewController:ProfilePage]; 

這應該工作

[self.navigationController presentModalViewController:ProfilePage animated:YES]; 
0

您可以使用下面的命令:

[self presentModalViewController:ProfilePage animated:YES] 
相關問題