更改与ios6和ios5兼容的设备方向
我需要:以编程方式将设备从纵向旋转到横向,与iOS6和iOS5兼容。更改与ios6和ios5兼容的设备方向,ios5,ios6,uiviewcontroller,uiinterfaceorientation,Ios5,Ios6,Uiviewcontroller,Uiinterfaceorientation,我需要:以编程方式将设备从纵向旋转到横向,与iOS6和iOS5兼容。 问题:我无法在ios6上使用[UIDevice setOrientation]函数 我拥有的:iOS6的代码: - (BOOL) shouldAutorotate { return YES; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationLandsc
问题:我无法在ios6上使用
[UIDevice setOrientation]
函数
我拥有的:iOS6的代码:
- (BOOL) shouldAutorotate
{
return YES;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}
iOS5的代码:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
因此,我需要编写在iOS5上循环的代码:
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
// [[UIDevice currentDevice] setOrientation] - I cannot use it
// ???
}
我通过设置状态栏方向来实现这一点,尝试在代码中执行:
[[sharedApplication] setStatusBarHidden:YES];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
当您需要纵向模式时,将状态栏设置为setStatusBarHidden:NO
,然后再次将状态栏方向设置为纵向UIInterfaceOrientationGrait