【问题标题】:Dismissing imagePickerController while holding the device landscape style causes my app to rotate into landscape mode (but my app is portrait only)在保持设备横向样式时关闭 imagePickerController 会导致我的应用程序旋转到横向模式(但我的应用程序仅是纵向的)
【发布时间】:2020-08-19 12:25:58
【问题描述】:

我有一个纵向和纵向颠倒应用程序。我展示了一个 imagePickerController,它允许我拍摄可以是横向或纵向的照片。拍照后,imagePicker 会验证我是否要使用拍摄的照片。如果我“侧身”握住我的设备(以横向方式),图像选择器视图将正常关闭,并且我的原始视图控制器将显示,除非它处于横向模式(包括键盘)。这应该是不可能的,因为我的应用只支持纵向。

关于如何让我的应用保持纵向模式以免 UI 混乱的任何想法?

这是我打开 imagePicker 之前的应用:

这是我关闭它之前的 imagePicker。虽然这个截图是纵向模式,但请想象我拿着设备 SIDEWAYS(横向):

这是由此产生的错误屏幕,我想防止:

【问题讨论】:

    标签: ios objective-c orientation uiimagepickercontroller


    【解决方案1】:

    我会首先检查 Info.plist 并确认方向正确并且不包含任何适用于 iphone 或 ipad 的横向选项:

    【讨论】:

    • plist 只包含纵向
    • 试试这段代码怎么样,放在调用图像选择器的视图控制器中的 viewdidload 方法之后: -(BOOL)shouldAutorotate { return NO; } -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { return NO; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationPortrait; }
    猜你喜欢
    • 2021-12-02
    • 2011-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-17
    • 2013-03-27
    相关资源
    最近更新 更多