我有两个视图控制器,foo
仅为纵向,bar
为纵向+横向。
当我将bar
推到foo
时,foo
始终以纵向方式开始。用户需要在推动后倾斜手机以使操作系统检测到新的方向。我喜欢的是foo
从加载的那一刻起就处于风景中,如果手机在被推动的那一刻就是风景。
如何在iOS6和7上实现这一目标?
答案 0 :(得分:0)
我会添加此代码
- (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;
}