0
我經歷了所有我可以在這裏找到的定向線程並實現了其中的一些定向線程。每個人工作90%。以下是我正在製作的應用程序的一些背景。 它有5個tabBarItems,每個顯然加載不同的視圖。其中一些觀點我想做風景和肖像,但是我只想成爲肖像。我有這個運作一些什麼。 HomeView需要是肖像。它加載肖像就好,並保持這種方式無論你如何旋轉手機但如果你切換到支持風景的另一個視圖,旋轉手機到風景,然後觸摸HomeView tabBarItem它將加載風景,即使它只設置爲只加載肖像。這裏是HomeView控制器當前半工作代碼:iOS 7界面定位2
- (void)viewDidLoad
{
[super viewDidLoad];
[self orientationPortrait];
NSLog(@"[INFO] %@ loaded",self);
}
-(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:true];
[self orientationPortrait];
}
-(void)viewWillAppear:(BOOL)animated
{
[self orientationPortrait];
}
-(void)viewWillDisappear:(BOOL)animated
{
//NSLog(@"viewWillDisappear -- Start");
[self orientationPortrait];
}
-(void) orientationPortrait {
TechBookAppDelegate *appDelegate = (TechBookAppDelegate *) [[UIApplication sharedApplication] delegate];
appDelegate.screenIsPortraitOnly = YES;
}
-(void) orientationBoth{
TechBookAppDelegate *appDelegate = (TechBookAppDelegate *) [[UIApplication sharedApplication] delegate];
appDelegate.screenIsPortraitOnly = FALSE;
}
在AppDelegate中
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
if(self.screenIsPortraitOnly == NO){
return UIInterfaceOrientationMaskAll;
} else {
return UIInterfaceOrientationMaskPortrait | !UIInterfaceOrientationMaskAll;
}
}
其他tabBarItems ViewControllers具有相同的只是他們稱之爲orientationBoth方法在需要的地方和他們叫orientationPortrait的viewWillDisappear,因爲我希望當視圖移回到HomeView,它會幫助將其設置爲肖像,但它似乎並沒有工作。
請指教,謝謝。