【问题标题】:Image orientation in iOS 7iOS 7 中的图像方向
【发布时间】:2013-11-15 08:08:36
【问题描述】:
UIImage *rotatedImage = [UIImage imageWithCGImage:[img CGImage] scale:1.0 orientation:imageView.image.imageOrientation];
// Setting img to imageview
[imageView setImage:rotatedImage];

以上代码在 iOS 6 中运行良好,但在 iOS 7 中不旋转图像。

我得到了正确的 imageOrientation 值,但静止图像没有旋转。

知道为什么吗?

谢谢。

【问题讨论】:

    标签: ios7 uiimage image-rotation uiimageorientation


    【解决方案1】:

    我认为“imageView.image.imageOrientation”属性存在逻辑错误。 您可能需要检查两种情况

    1. imageView.image 不应为 nil,否则,旋转图像将不起作用,并将返回相同方向的图像。

    2. “imageView.image”和“img”,两个 UIImage 变量都指向同一个图像引用。因此,输出是相同的。

    我希望这可以解决您的问题。谢谢!!

    【讨论】:

    • 但为什么这可能只是 iOS 7 而不是 iOS 6 中的逻辑问题
    • Subhash,是否可以在这行代码之前提供更多代码 sn-p 以便我可以看到有关 imageView.image 的一些信息?
    • Basil,我有一个具有 UIImageViews 的滚动视图。用户水平滚动图像。一旦图像视图离开屏幕,我将其图像设置为 nil,当它出现在屏幕上时,我将其图像从我的图像名称字典。因此,当我阅读 imageView.image 时,该图像的图像为零。但它仍然适用于 iOS 6。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-11-03
    • 2013-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多