简体   繁体   English

iphone 4和iphone 5的相机覆盖高度

[英]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. 我正在使用标准的UIImagePickerController并使用相机覆盖视图,默认控件。 I've got an external nib file which I load the overlay view from. 我有一个外部nib文件,我加载了覆盖视图。 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. 问题是视图似乎是460,所以不完全包含iphone 5上的摄像头视图。我想使用自动布局来解决这个问题,但我不知道如何告诉笔尖调整它的尺寸可以是iphone 4或iphone 5的高度。

I thought about using setFrame, but that's very un-auto layout. 我想过使用setFrame,但这是非自动布局。 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. 我还想过有2个不同的nib文件,一个用于iphone 4,另一个用于iphone 5,但这似乎也是错误的方法。 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. 您可以根据手机尺寸以编程方式加载其他cameraOverlayView XIB。 The camera controls strip is about 54px tall on 480h screens, and about 96px tall on 568h screens. 相机控制条在480h屏幕上高约54px,在568h屏幕上高约96px。

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. 或者,您当然可以设置适当的自动调整大小掩码设置您的XIB,但是需要在代码中执行setFrame以获得正确的尺寸。

So either way, you're writing some code to detect the screen bounds and either loading a different XIB or doing a setFrame. 无论哪种方式,您都要编写一些代码来检测屏幕边界,并加载不同的XIB或执行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? 我现在还没有使用笔尖一段时间(首选故事板)但是我相信到目前为止你所拥有的是笔尖中的UIImageView,对吧? 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. 然后在你的m文件中,检查设备的尺寸(很多人最近询问了如何检查屏幕尺寸),然后根据找到的尺寸设置uiimageview框架。 It should work ;) 它应该工作;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM