【发布时间】:2012-12-27 12:19:04
【问题描述】:
我创建了一个仅纵向的 iphone 应用程序,即使我在旋转设备时也制作了一个支持横向的视图 在 iOS6 中一切正常,但是当我在 iOS5 上运行它时,横向模式不正确,它显示了一些令人讨厌的图像。 (两个设备都是 ipod 3.5" 视网膜显示屏)
为什么会这样??
在此处添加我的代码和屏幕截图
在 iOS6 中 在 iOS 5 中
-(无效)viewDidLoad { [超级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)];
}
}
【问题讨论】:
-
为什么在框架集中给出 neg 坐标:imageScrollView.frame =CGRectMake(-50, -100, 400, 620);
-
因为我正在放大那里,如果我没有给出负坐标,即使在 ios6 也不会工作
-
不,它可以在没有负坐标的情况下工作。
标签: iphone objective-c ios uiimageorientation