【问题标题】:how to rotate camera preview mode in iphone如何在iphone中旋转相机预览模式
【发布时间】:2012-10-16 15:27:32
【问题描述】:

我正在尝试在使用相机拍摄图像时旋转UIImage。但是,我只能在 portrait 模式下获得预览。 landscape模式下如何显示预览图?

【问题讨论】:

标签: iphone


【解决方案1】:

Reading the documentation for UIImagePickerController 揭示了这个有趣的花絮:

UIImagePickerController 类仅支持纵向模式。这个 类旨在按原样使用,不支持子类化。

尽管有 Apple 的警告,但有一种处理方式:

您可以在委托类中订阅轮换通知:

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

然后,根据设备的当前旋转,您可以将CGAffineTransform 应用于您的叠加视图。这种转换的一个例子可以是found here。该特定答案在 iOS 6 中对您没有帮助,因为您的 UIViewController 子类永远不会调用 shouldAutorotateToInterfaceOrientation。您最好的版本策略是订阅通知。请记住,您将在这里进行全手动操作,最好的办法是找出一种仅支持纵向模式的方法。

此外,请确保在完成后平衡通知调用与此调用:

[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-05
    • 2013-01-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多