简体   繁体   English

仅在 iPhone 上旋转图像?

[英]Rotate an image on iPhone only?

How would one rotate an image using the following line of code but for iPhone only?如何使用以下代码行旋转图像但仅适用于 iPhone?

PhotoView.transform=CGAffineTransformMakeRotation(M_PI*0.5);

My app uses a UIScrollView.我的应用程序使用 UIScrollView。 In the scrollView are thumbnail images.在滚动视图中是缩略图。 When a thumbnail is tapped, a segue is triggered to load an image in a new view controller, but for some reason, the image loads on its side on iPhone 4 (it loads perfectly straight on iPad mini)当缩略图被点击时,会触发一个 segue 将图像加载到新的视图控制器中,但由于某种原因,图像在 iPhone 4 上加载到它的一侧(它在 iPad mini 上完美地直接加载)

I used the following if statement format to no avail...我使用了以下 if 语句格式无济于事...

 if ([[UIScreen mainScreen] bounds].size.height == 480)
    {
        // iPhone, iPod Touch
     ...
    }

My question: Is there another way to explicitly rotate the image on iPhone devices only?我的问题:是否有另一种方法可以仅在 iPhone 设备上显式旋转图像? The following line successfully rotates the image correctly for iPhone uses, but conversely erroneously loads it for the iPad.下面一行成功地为 iPhone 正确旋转了图像,但相反地为 iPad 错误地加载了它。

PhotoView.transform=CGAffineTransformMakeRotation(M_PI*0.5);

How can one programmatically rotate an image for iPhone 4 only?如何以编程方式旋转仅适用于 iPhone 4 的图像? Additional info: this is technically an iPhone app under build settings.附加信息:这在技术上是构建设置下的 iPhone 应用程序。

Try this尝试这个

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad){
}
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM