【问题标题】:different behaviours for UIImage Orientation in iOS6 and iOS5iOS6 和 iOS5 中 UIImage Orientation 的不同行为
【发布时间】: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


【解决方案1】:

InterfaceOrientation 方法在 ios6 中已弃用。 因此,如果您希望 ios5 和 ios6 都支持您的方向,则必须为 ios6 编写两个额外的方法以及

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// your customisation will go here
}

ios6 的两个额外方法

    - (BOOL)shouldAutorotate
    {
        return YES;
    }

    - (NSUInteger)supportedInterfaceOrientations
       {
   // your customisation will go here
       }

享受编程!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-06-15
    • 1970-01-01
    • 2012-09-17
    • 2012-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多