简体   繁体   中英

Rotate an image on iPhone only?

How would one rotate an image using the following line of code but for iPhone only?

PhotoView.transform=CGAffineTransformMakeRotation(M_PI*0.5);

My app uses a 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)

I used the following if statement format to no avail...

 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? The following line successfully rotates the image correctly for iPhone uses, but conversely erroneously loads it for the iPad.

PhotoView.transform=CGAffineTransformMakeRotation(M_PI*0.5);

How can one programmatically rotate an image for iPhone 4 only? Additional info: this is technically an iPhone app under build settings.

Try this

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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