2014-04-08 55 views
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,它会帮助将其设置为肖像,但它似乎并没有工作。

请指教,谢谢。

回答

1

我已解决此问题,方向更改时重新组织HomeViewController的布局。