ios - 需要停止相机覆盖的旋转

标签 ios uiimagepickercontroller

在我的通用应用程序中,我在相机界面上创建了一个相机覆盖 View 。请注意,我的应用已锁定为纵向模式。但是,当我改变 iPad 的界面方向时,叠加层也会随之旋转。但我不想要那样!

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

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

enter image description here

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

enter image description here

最佳答案

确保在您的应用设置中禁用除纵向以外的所有方向。 enter image description here

编辑

您还可以创建自定义 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

关于ios - 需要停止相机覆盖的旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21400761/

相关文章:

ios - 在 Swift 中调用 CGPatternCreate

ios - 使用 UIImagePickerController 拍摄两次照片

objective-c - iOS8 中的相机旋转和 OverlayView

objective-c - 如何在 iOS 中保存 EXIF 元数据?

iphone - 设置 UIImagePickerController 的 UIBarStyle

ios - 所有 Firebase 调用完成后如何重新加载数据?

ios - 访问关系时核心数据privateQueue performBlockAndWait死锁

ios - 有没有办法将ipa文件转换为xcode文件?

iphone - 自定义 View 中的 UIImagePickerController 不显示相机

ios - 即使在 mergeChangesFromContextDidSaveNotification 之后停止 CoreData 缓存结果