簡體   English   中英

在iOS上從橫向視圖切換到縱向視圖

[英]Switching from Landscape View to Portrait View on iOS

我的應用程序中有兩個視圖。 一種(默認情況下)是風景。 當用戶單擊某個菜單時,我需要顯示“縱向”視圖。

我有所有的代碼,我正在嘗試使用此:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

      return (interfaceOrientation == UIInterfaceOrientationPortrait);

}

但是該應用仍會在“景觀”中顯示下一個視圖。 我不知道這個。 任何幫助都會很棒。

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);
}

您可以在viewWillAppear方法中使用以下代碼來制作人像。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM