2012-10-16 128 views
1

我在我的應用程序中有兩個視圖。一個(默認)是風景。當用戶點擊某個菜單時,我需要出現一個縱向視圖。從橫向視圖切換到iOS上的縱向視圖

我已經具備了所有的代碼,我嘗試使用此:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 

     return (interfaceOrientation == UIInterfaceOrientationPortrait); 

} 

,但應用程序仍顯示在園林中的下一個視圖。我無法弄清楚這一點。任何幫助都會很棒。

回答

0

您可以使用下面的代碼在你的viewWillAppear方法,使您的視圖肖像。

[[UIDevice currentDevice] performSelector:NSSelectorFromString(@"setOrientation:") withObject:(id)UIInterfaceOrientationPortrait]; 
+0

它給我的錯誤: 'NSInteger的'(又名 'INT')以 'ID' 的演員是不允許使用ARC。 – nworksdev

+0

你必須禁用ARC才能使用此代碼 –

+0

菜鳥錯誤。謝謝! – nworksdev

1
You can not do it using navigation controller but if you are presenting your view then it is possible to do that and make sure when you are presenting your view animation should be NO. 
It works for me very well. 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 
相關問題