【问题标题】:need to stop rotation of camera overlay需要停止相机覆盖的旋转
【发布时间】:2014-02-19 11:11:29
【问题描述】:

在我的universal application 中,我正在我的相机界面上创建一个camera overlay view。请注意,我的应用程序已锁定 portrait mode。但是,当我更改 iPad 的界面方向时,叠加层也会随之旋转。但我不想那样!

如何阻止它在界面中随旋转而旋转?

这是 iPAD 上的叠加层在纵向上的外观(主页按钮向下):

这就是在 iPAD 上横向旋转的方式(左侧带有主页按钮):

【问题讨论】:

    标签: ios uiimagepickercontroller


    【解决方案1】:

    确保在应用设置中禁用除纵向以外的所有方向。

    编辑

    您还可以像这样创建自定义UIImagePickerController 类:

    @interface MyImagePickerController : UIImagePickerController
    
    @end
    
    @implementation MyImagePickerController
    
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
    {
        return toInterfaceOrientation == UIInterfaceOrientationPortrait;
    }
    
    - (BOOL)shouldAutorotate
    {
        return NO;
    }
    
    - (NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskPortrait;
    }
    
    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
    {
        return UIInterfaceOrientationPortrait;
    }
    
    @end
    

    【讨论】:

    • 是的,我已经做到了.. 除了覆盖之外没有任何旋转.. 此外,相机的圆形按钮也会改变它的位置。正如你在截图中看到的那样......
    • yupp .. 我继承了 UIImagePickerController 的子类,然后实现了你说的方法。但是,我对子类化持怀疑态度.. Apple 强烈反对这样做..
    • 它还说它只支持纵向模式,你所做的就是强制执行(他们没能做到)。
    猜你喜欢
    • 2020-06-18
    • 1970-01-01
    • 2022-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-23
    相关资源
    最近更新 更多