简体   繁体   中英

How to get an image taken from the camera to take up the entire screen

I have dragged a UIImageView onto the UIViewController window in storyboard. I used the handles to make it take up the entire window. I set the mode of the UIImageView to "Aspect Fit". My goal is for the picture to take up the entire window when the iPhone is held in the same orientation that the image was taken.

But for some reason there's a little bit of space above and below every image.

Also I have it set up for the navigation bar and status bar to disappear when the user touches the image by using a hidden UIButton. This works okay except that the image shifts down when the navigation and status bars come back into view. The image only shifts down when I have this code:

    self.navigationController.navigationBarHidden = YES;
    self.navigationController.navigationBarHidden = NO;

which I use to get the navigationBar to redraw itself below the statusbar because sometimes the navigationbar will be drawn underneath the statusbar (this happens when making the navigationbar and statusbar reappear at the same time.)

How can I make my images display full screen without all these quirks?

EDIT:

I think it may have something to do with this:

The camera's aspect ratio is 4:3 and the screen's aspect ratio is 3:2. So there is simply no way for the camera picture to fill the screen unless you're willing to crop is to 3:2. To do that, apply an appropriate scale transform.

is it possible to apply an affinetransform to an image in a uiimageview?

You'll want to set wantsFullScreenLayout to YES on your instance of UIViewController . From the documentation for wantsFullScreenLayout .

When a view controller presents its view, it normally shrinks that view so that its frame does not overlap the device's status bar. Setting this property to YES causes the view controller to size its view so that it fills the entire screen, including the area under the status bar. (Of course, for this to happen, the window hosting the view controller must itself be sized to fill the entire screen, including the area underneath the status bar.) You would typically set this property to YES in cases where you have a translucent status bar and want your view's content to be visible behind that view.

If this property is YES, the view is not resized in a way that would cause it to overlap a tab bar but is resized to overlap translucent toolbars. Regardless of the value of this property, navigation controllers always allow views to overlap translucent navigation bars.

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