我创建了一个只有纵向的iphone应用程序,即使我在旋转设备的同时制作了一个支持横向的视图 在iOS6中一切正常但是当我在iOS5上运行时,横向模式不正确它会显示一些讨厌的图像。 (两款设备均为ipod 3.5“视网膜显示器)
为什么会这样?
在此处添加我的代码和屏幕截图
在iOS6中 iOS 5中的
- (void)viewDidLoad { [super viewDidLoad];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didRotate:)
name:UIDeviceOrientationDidChangeNotification
object:nil];
}
- (void)didRotate:(NSNotification *)notification {
UIDeviceOrientation orientation = [[notification object] orientation];
if (orientation == UIDeviceOrientationLandscapeLeft) {
[self.grpView setTransform:CGAffineTransformMakeRotation(M_PI / 2.0)];
imageScrollView.frame =CGRectMake(-50, -100, 400, 620);
} else if (orientation == UIDeviceOrientationLandscapeRight) {
[self.grpView setTransform:CGAffineTransformMakeRotation(M_PI / -2.0)];
} else if (orientation == UIDeviceOrientationPortraitUpsideDown) {
[self.grpView setTransform:CGAffineTransformMakeRotation(M_PI)];
} else if (orientation == UIDeviceOrientationPortrait) {
[self.grpView setTransform:CGAffineTransformMakeRotation(0.0)];
}
}
答案 0 :(得分:1)
在ios6中不推荐使用InterfaceOrientation方法。 因此,如果您希望ios5& ios6,你必须为ios6和
编写两个额外的方法 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// your customisation will go here
}
ios6的两个额外方法
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
// your customisation will go here
}
享受编程!