开发者

Is there a built in way to make my UIImageView fit the entire contents of a UIImage? Am I just missing something?

I have a modalView that I am presenting with the UIModalPresentationPageSheet style, and this view has a scrollView, and an mageView inside of that scrollView to make it so I can show images, and allow for user manipulation such as zooming, etc.

In viewDidLoad this is how I am setting everything up:

CGRect imgFrame = CGRectMake(0, 0, img.size.w开发者_如何学Cidth, img.size.height);
imageView.frame = imgFrame;
[imageView setImage:img];

Which works fine, but the problem I'm having is that if I have an image that is bigger than the somewhat small modalView size when in landscape mode (due to the UIModalPresentationPageSheet style), it doesn't zoom out and scale so I can see the whole thing, it just shows me 2/3 of the image, and in order to see there is more I have to actually zoom out.

I have set the contentMode to UIViewContentModeScaleAspectFit, and it still didn't change anything.

Am I missing something?


Set the image view's frame to have a max width and height of the screen's dimensions depending on the current orientation.

Something like:

CGRect imgFrame = CGRectMake(0, 0, min(320 ,img.size.width), min(480, img.size.height);

That would apply to portrait mode on an iPhone (different for iPad). You'll have to reset that frame when there is an orientation change.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜