简体   繁体   English

如何从相机拍摄图像以占据整个屏幕

[英]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. 我已将UIImageView拖到故事板中的UIViewController窗口。 I used the handles to make it take up the entire window. 我使用手柄使它占据了整个窗口。 I set the mode of the UIImageView to "Aspect Fit". 我将UIImageView的模式设置为“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. 我的目标是当iPhone保持与拍摄图像相同的方向时,图像占据整个窗口。

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. 此外,当用户使用隐藏的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. 相机的宽高比为4:3,屏幕的宽高比为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. 所以除非你愿意裁剪到3:2,否则根本无法让相机图片填满屏幕。 To do that, apply an appropriate scale transform. 为此,请应用适当的比例变换。

is it possible to apply an affinetransform to an image in a uiimageview? 是否可以在uiimageview中对图像应用仿射变换?

You'll want to set wantsFullScreenLayout to YES on your instance of UIViewController . 您需要在UIViewController实例wantsFullScreenLayout设置为YES From the documentation for wantsFullScreenLayout . 来自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. 将此属性设置为YES会导致视图控制器调整其视图大小,使其填满整个屏幕,包括状态栏下的区域。 (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. (当然,为此,托管视图控制器的窗口本身必须调整大小以填充整个屏幕,包括状态栏下方的区域。)如果您具有半透明状态,通常会将此属性设置为YES栏,并希望您的视图内容在该视图后面可见。

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. 如果此属性为YES,则视图的调整大小不会导致它与标签栏重叠,但会调整大小以重叠半透明工具栏。 Regardless of the value of this property, navigation controllers always allow views to overlap translucent navigation bars. 无论此属性的值如何,导航控制器始终允许视图与半透明导航栏重叠。

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

相关问题 获取从相机/照片库拍摄的图像的名称 - Get the name of an image taken from camera/photo library 如何从UIImagePicker相机拍摄后裁剪图像? - How to crop image after taken from UIImagePicker Camera? 如何显示科尔多瓦从相机拍摄的图像? (Xcode / iOS) - How to show image taken from camera in Cordova? (Xcode/iOS) 如何检测照片库中的图像是由iPhone相机拍摄还是导入 - how to detect if image from photo library was taken by iPhone camera or imported 如果使用 UIImagePickerControllerSourceTypeCamera 从相机拍摄图像,则不会检测到图像 - Image is not detected if taken from camera Using UIImagePickerControllerSourceTypeCamera iPhone如何在相机应用程序中获得照片拍摄效果? - iPhone How to get photo taken effect like in camera application? 如何拍摄整个视图的iPhone屏幕截图,包括屏幕外的部分? - How to take an iPhone screenshot of entire view including parts off screen? 保存使用相机拍摄的图像或从相机胶卷中选择时的长时间延迟 - iPhone - Long delay when saving image taken with camera or chosen from camera roll - iPhone 如何编辑直接从相机拍摄的照片并将其上传到 iphone? - How to edit photo directly taken from camera and upload it on iphone? 如何通过我们的应用程序重命名从相机拍摄的图像? - how to rename the images taken from camera through our app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM