在推视图控制器上使用当前方向
问题描述:
我有两个视图控制器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;
}
这并不遗憾的是工作。 – Morrowless
你试过这个吗? http://*.com/questions/14402401/viewcontroller-in-uinavigationcontroller-orientation-change –
http://*.com/questions/14633213/force-portrait-orientation-while-pushing-from-landscape-view-控制器 - 也试试这个 –