在推视图控制器上使用当前方向

问题描述:

我有两个视图控制器foo,它只是肖像,而bar是肖像+风景。 当我将bar推入foo时,foo始终以纵向方向开始。用户需要在推动后倾斜手机以使操作系统检测到新的方向。如果手机在被推动的时候处于风景状态,我希望foo从装入的那一刻开始处于横向状态。在推视图控制器上使用当前方向

这怎么能在iOS6和7上实现呢?

我想补充一点的代码

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    // Adapt the orientation with your need 
    return (interfaceOrientation != UIInterfaceOrientationPortrait && 
      interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); 
} 

- (BOOL)shouldAutorotate { 
    UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation]; 

    if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) 
     return YES; 
    else 
     return NO; 
} 

-(NSUInteger)supportedInterfaceOrientations{ 
    return UIInterfaceOrientationMaskLandscapeLeft; 
} 
+0

这并不遗憾的是工作。 – Morrowless

+0

你试过这个吗? http://*.com/questions/14402401/viewcontroller-in-uinavigationcontroller-orientation-change –

+0

http://*.com/questions/14633213/force-portrait-orientation-while-pushing-from-landscape-view-控制器 - 也试试这个 –