【发布时间】:2017-12-14 18:58:59
【问题描述】:
我使用UIImagePickerController 在我的应用中实现了一个自定义相机。我之前通过申请this transformation使相机全屏:
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
ipc = [[UIImagePickerController alloc] init];
ipc.delegate = self;
ipc.sourceType = UIImagePickerControllerSourceTypeCamera;
ipc.showsCameraControls = NO;
[[NSBundle mainBundle] loadNibNamed:@"SnapItCameraView" owner:self options:nil];
self.overlayView.frame = ipc.cameraOverlayView.frame;
ipc.cameraOverlayView = self.overlayView;
self.overlayView = nil;
//For iphone 5+
//Camera is 426 * 320. Screen height is 568. Multiply by 1.333 in 5 inch to fill vertical
CGAffineTransform translate = CGAffineTransformMakeTranslation(0.0, 71.0); //This slots the preview exactly in the middle of the screen by moving it down 71 points
ipc.cameraViewTransform = translate;
CGAffineTransform scale = CGAffineTransformScale(translate, 1.333333, 1.333333);
ipc.cameraViewTransform = scale;
ipc.showsCameraControls = NO;
ipc.tabBarController.tabBar.hidden = YES;
ipc.allowsEditing = NO;
[self presentViewController:ipc animated:YES completion:nil];
}
但是,相机并没有填满 iPhone X 的屏幕。它与屏幕顶部齐平,但底部有一个黑条。
我认为问题在于 1.3 是垂直填充屏幕的错误比例。我希望相机能填满 iPhone X 手机的整个屏幕。
【问题讨论】:
-
其他@Matt:“我认为问题是 1.3 是垂直填充屏幕的错误比例”这听起来很合理。你能澄清一下问题是什么吗?您没有显示足够的代码来重现问题,甚至不清楚您认为自己要做什么。
-
@matt 对此感到抱歉。我的说明更好了吗?
-
是的! — 我没有 iPhone X,所以无法测试。但是让我问你这个问题:如果你把硬编码的数字改成别的东西(更大?),会更好吗?
标签: ios objective-c uiimagepickercontroller cgaffinetransform iphone-x