iphone - 如何让从相机拍摄的图像占据整个屏幕

标签 iphone ios cocoa-touch

我已将 UIImageView 拖到 Storyboard 中的 UIViewController 窗口中。我用 Handlebars 让它占据了整个 window 。我将 UIImageView 的模式设置为“Aspect Fit”。我的目标是当 iPhone 的握持方向与拍摄图像时的方向相同时,照片会占据整个窗口。

但出于某种原因,每张图片的上方和下方都有一点空间。

我还设置了当用户使用隐藏的 UIButton 触摸图像时导航栏和状态栏消失。这工作正常,除了当导航栏和状态栏重新出现时图像向下移动。只有当我有这段代码时,图像才会向下移动:

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

我用它来让导航栏在状态栏下方重新绘制自己,因为有时导航栏会绘制在状态栏下方(当导航栏和状态栏同时重新出现时会发生这种情况。)

如何让我的图像全屏显示而没有所有这些怪癖?

编辑:

我认为这可能与此有关:

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.

是否可以对 uiimageview 中的图像应用仿射变换?

最佳答案

您需要在 UIViewController 实例上将 wantsFullScreenLayout 设置为 YES。来自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.

关于iphone - 如何让从相机拍摄的图像占据整个屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8749660/

相关文章:

objective-c - 比较文章的 NSString 统计(即 "the"和 "a")

iphone - Monotouch.Dialog - 设置后退按钮

ios - Objective-C,很高兴认识你和你的 UIImagePickerController

ios - iPhone - 什么时候弃用的方法通常会过时?

iphone - 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“错误:无法打开数据库并显示消息“不是错误”。

ios - moveRowAtIndexPath - 在部分之间移动单元格

ios - 应用程序崩溃时无法解锁 iPhone 或通过锁定屏幕(即使在重启后)

iphone - 现在开始构建 iOS 应用程序并在 1-2 个月内发布时使用哪个 iOS 版本?

ios - 通过字符串运行一堆方法并接收一个值

ios - 如何在 iphone 应用程序开发中将数据从一个版本保存到另一个版本?