簡體   English   中英

不需要的 UIView 自動旋轉:導航 Controller 推送

[英]Unwanted UIView Autorotating: Navigation Controller Push

我有一個導航 controller ,它通過縱向。 然后,在某個時刻,我推到一個顯示圖形的視圖,我只想以橫向顯示,甚至根本不以縱向顯示(這搞砸了視圖的外觀)。

在這個視圖中,GraphViewController,我有以下方法:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}

當視圖第一次被推送時,它以縱向模式出現。 如果我旋轉手機,視圖也會旋轉成橫向(而不是倒置縱向)。 但我希望它永遠不要處於縱向模式,即使它啟動時也不行。 我已經驗證通過添加 NSLog 來調用此方法。

我看到了這些帖子,但無法讓它發揮作用。 謝謝!!

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

暫無
暫無

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

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