1
我有一個標籤欄應用程序,其中我有3個不同的視圖,每個都有自己的視圖控制器。Tabbar導航應用程序,允許一個視圖旋轉,而其他人不需要
在標籤條碼中我有這個來處理旋轉。
#import "RotatingTabBarController.h"
@implementation RotatingTabBarController
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return [self.selectedViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}
@end
在第二視圖控制器
那時,我想這取決於設備的方向旋轉,我有:
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
爲此,我不想旋轉,我有此方法設置的其他兩個視圖。
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
問題:這樣當u旋轉他們留在肖像模式,其所需的設備本工作在圖1和圖3的罰款。在視圖2中,我旋轉到橫向,視圖按預期方式工作並旋轉到橫向。但是當在景觀模式下在視圖2中單擊視圖1或視圖3選項卡時,視圖1和視圖3處於橫向模式。
我不知道如何強制他們在縱向即使視圖2旋轉到景觀。
任何人都知道如何做到這一點?
這應該不是真的可以從應用程序啓動除了隨時使用。在應用程序生命週期的中途強制進行狀態欄定位非常糟糕,可能會產生意想不到的後果。 – 2012-06-24 23:06:36
有沒有官方消息說這個?有些應用程序有例如必要時切換方向的「觀察模式」以及需要改變方向的一系列其他情況。 – Kalle 2012-06-25 13:14:06
「但是,如果您的應用程序具有可旋轉的窗口內容,則不應該使用此方法任意設置狀態欄方向」 - http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIApplication_Class/Reference /Reference.html – 2012-06-25 18:27:26