IOS力装置的旋转
问题描述:
这里是我的代码:IOS力装置的旋转
if ([[UIApplication sharedApplication] statusBarOrientation] != UIInterfaceOrientationLandscapeLeft) {
[appDelegate makeTabBarHidden:TRUE];
self.navigationController.navigationBarHidden = YES;
[UIView beginAnimations:@"newAlbum" context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(addResultGraph)];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:YES];
// Then rotate the view and re-align it:
CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(90.0 * M_PI/-180.0);
landscapeTransform = CGAffineTransformTranslate(landscapeTransform, +90.0, +90.0);
[self.navigationController.view setTransform:landscapeTransform];
[UIView commitAnimations];
}
以及与此,从纵向模式时,新的视图 - 控制在landscapeleft模式下显示,并一切正常,但我的问题是:如果我旋转该设备从横向模式纵向,状态栏以纵向模式出现,并且视图控制器保持横向模式....
我该如何解决这个问题? 在此先感谢!
答
您可以重新实现shouldAutorotateToInterfaceOrientation
方法和做类似
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
这种方式,您只启用左排列,如果你旋转你的设备肖像,界面不会转动
工作正常如果我阻止iPhone旋转(绝对) – ghiboz