UIImagePickerController没有填充屏幕 [英] UIImagePickerController doesn't fill screen

查看:92
本文介绍了UIImagePickerController没有填充屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

截图http://i39.tinypic.com/oiermb.png

我正在为UIImagePickerController添加一个自定义叠加层,并且视图底部有一个持久的黑条。这是我实例化控制器的代码。

I'm adding a custom overlay to the UIImagePickerController and there is a persistant black bar at the bottom of the view. Here is my code to instantiate the controller.

- (UIImagePickerController *)imagePicker {
    if (_imagePicker) {
        return _imagePicker;
    }

    _imagePicker = [[UIImagePickerController alloc] init];
    _imagePicker.delegate = self;

    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
        _imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;

        _imagePicker.showsCameraControls = NO;

        _imagePicker.wantsFullScreenLayout = YES;
        _imagePicker.navigationBarHidden = YES;
        _imagePicker.toolbarHidden = YES;

    } else {
        _imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    }

    return _imagePicker;
}

返回的控制器以模态显示并且工作正常(即显示全屏)当我没有隐藏相机控件时。

The returned controller is displayed modally and works just fine (i.e. displays full screen) when I'm not hiding the camera controls.

感谢Ole的建议我使用了这段代码:

Thanks to Ole's suggestion I got it working with this code:

// Resize the camera preview
        _imagePicker.cameraViewTransform = CGAffineTransformMakeScale(1.0, 1.03);

高度增加3%就可以了。当我在屏幕底部添加自定义工具栏时,窗口上不再有可见的黑条。

A 3% increase in height worked just fine. When I add my custom toolbar at the bottom of the screen there is no longer a visible black bar across the window.

推荐答案

相机的宽高比为4:3,屏幕的宽高比为3:2。因此除非你愿意裁剪到3:2,否则根本无法让相机图片填满屏幕。为此,请应用适当的比例变换。

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.

这篇关于UIImagePickerController没有填充屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆