I want to display a picture taken by the camera and scale it down AND keep scale ratio.
The different models of iPhones all have different resolution of photos.
I've tried some assignments with bounds etc but no luck - giving me a lvaule requires erro开发者_如何学Gor.
My image from the camera is called "imageA" and the UIImageView is "imageView"
Any ideas would be appreciated.
I think you just need to set the content mode of the UIImageView you are using to display the image to "aspect fit".
Those lvalue errors are happening because the bounds themselves are a property but the coordinates in them are struct members (even though the syntax is the same) - you can't directly get or set them. So to change the bounds you'd want something like:
CGRect imageBounds = imageView.bounds;
imageBounds.x += 10;
imageView.bounds = imageBounds;
Calling sizeToFit
on the UIImageView after setting the image should get it to automatically resize its frame around it.
And yes, per Walter's answer if you set the view's contentMode
to UIViewContentModeScaleAspectFit
that should get it to preserve the aspect ratio.
精彩评论