简体   繁体   中英

Camera Overlay height for both iphone 4 and iphone 5

I'm using the standard UIImagePickerController and using a camera overlay view with it, default controls. I've got an external nib file which I load the overlay view from. The problem is that the view seems to be at 460, so doesn't fully encompass the camera view on iphone 5. I'd like to approach this using auto layout, but I'm not sure how to tell the nib to adjust it's size to be either a height for iphone 4 or iphone 5.

I thought about using setFrame, but that's very un-auto layout. I've also thought about having 2 different nib files, one for iphone 4 and one for iphone 5, but that seems to be the wrong approach too. I'm guessing there's some way to tell the nib to fill the current camera view, but I'm not sure what it is. Can someone recommend the "correct" way to handle this?

You can programmatically load a different cameraOverlayView XIB based on the phone dimensions. The camera controls strip is about 54px tall on 480h screens, and about 96px tall on 568h screens.

Alternatively, you can certainly design your XIB with auto resizing masks set appropriately, but will need to then do a setFrame in code to get the right dimensions.

So either way, you're writing some code to detect the screen bounds and either loading a different XIB or doing a setFrame.

I haven't used nibs for a while now (preferred storyboard) but I believe what you have so far is a UIImageView in the nib, right? Make that an outlet. And then in your m file, check for dimension of the device (many people have asked this recently how to check screen dimension), then you set the uiimageview frame based on the found dimensions. It should work ;)

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