views:

15

answers:

1

I'm looking to change the phone's rotation based on the size of an image. is there a way to detect if the image has 480px x 300px dimensions then use landscape rotation and vice versa?

I have many photos some of which are best view landscape and other best viewed in portrait mode.

thanks for any help.

+1  A: 

Think hard about whether you want to rotate the whole UIView that the image is on, versus just doing a rotation transform on the image, so it's turned 90 degrees inside a view that's still portrait mode. When I came up against this issue myself recently, I chose the latter. The whole rest of my app is locked in portrait mode, and to have this one view re-orient its whole thing to be landscape was just weird. Instead I float the image out in a UIView up on top of everything else, and rotate it if that's the best-fit orientation of the image.

Dan Ray
I like the idea of floating the image out in a UIView.I have 500+ images and some of them get distorted in portrait mode and some of them get distorted in landscape. I'm finding it difficult getting them displayed properly.thanks for your post.
hanumanDev
Sure thing. If it helps, my approach is that I have a bunch of images to pick from, and when the user taps one, I do UIView animations to expand it from where it is to a full-screen frame, with contentMode set to Aspect Fit. Then I have it set up as a delegate to receive orientation change notifications, and when I see I've gone landscape, I redo my frame to put the top left corner at the (new) 0,0, thereby rotating my content.
Dan Ray