【问题标题】:Fullscreen camera in iPhone 5siPhone 5s 的全屏摄像头
【发布时间】:2014-06-27 10:17:52
【问题描述】:

我创建了一个带有自定义视图的相机叠加层,并且我试图通过应用缩放和平移使相机处于全屏状态。它在 iPhone 5 中运行良好,但在 iPhone 5s 中却不行。我尝试了很多部分代码,但仍然没有发现问题。这是我的代码:

if ([[UIScreen mainScreen] bounds].size.height == 568) {
    CGAffineTransform translate = CGAffineTransformMakeTranslation(0.0, 71.0);
    CGAffineTransform scale = CGAffineTransformScale(translate, 1.333333, 1.333333);
    imagePicker.cameraViewTransform = scale;
}

顺便说一下,我在 iOS 7 中进行测试。

感谢您的帮助。

【问题讨论】:

    标签: iphone ios7 camera fullscreen


    【解决方案1】:

    将这行代码放入您的自定义相机 oveylay 类中。它适用于 iPhone5s。

            CGSize screenSize = [[UIScreen mainScreen] bounds].size;
    
            int heightOffset = 120;
    
            float cameraAspectRatio = 4.0 / 3.0; //! Note: 4.0 and 4.0 works
            float imageWidth = floorf(screenSize.width * cameraAspectRatio);
            float scale = ceilf(((screenSize.height + heightOffset) / imageWidth) * 10.0) / 10.0;
    
            self.imagePickerController.cameraViewTransform = CGAffineTransformMakeScale(scale, scale);
    

    【讨论】:

    • 嗨。感谢您的重播,但它仍然无法正常工作。我添加了一张图片来查看渲染。我不明白的是它在 iPhone 5 上工作,而不是在 5s 上工作,即使它们的尺寸相同。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-26
    • 2015-06-03
    • 2022-11-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多