UIApplicationInvalidInterfaceOrientation [iPad]

问题描述 投票:0回答:0

- 支持的方向与应用程序没有共同的方向,并且 [_UIDatePickerContainerViewController shouldAutorotate] 返回 YES

致命异常:UIApplicationInvalidInterfaceOrientation 0 CoreFoundation 0x9d94 __exceptionPreprocess 1 libobjc.A.dylib 0x183d0 objc_exception_throw 2 CoreFoundation 0xf7300 __CFDictionaryCreateGeneric 3 UIKitCore 0x243b54 -[UIViewController __supportedInterfaceOrientations] 4 UIKitCore 0x24377c -[UIViewController __withSupportedInterfaceOrientation:apply:] 5 UIKitCore 0x175560 -[UIViewController setInterfaceOrientation:] 6 UIKitCore 0x172090 -[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:] 7 UIKitCore 0x1d940 -[UIView(内部)_didMoveFromWindow:toWindow:] 8 UIKitCore 0xd0b68 __45-[UIView(层次结构)_postMovedFromSuperview:]_block_invoke 9 CoreAutoLayout 0x4fcc -[NSISEngine withBehaviors:performModifications:] 10 UIKitCore 0x105c200-[UIView _postMovedFromSuperview:] 11 UIKitCore 0x1e8b8 -[UIView(内部)_addSubview:positioned:relativeTo:] 12 UIKitCore 0x3d9988 __67-[UIViewControllerBuiltinTransitionViewAnimator animateTransition:]_block_invoke_2 13 UIKitCore 0x30f58 +[UIView(动画) performWithoutAnimation:] 14 UIKitCore 0x3c0bac __67-[UIViewControllerBuiltinTransitionViewAnimator 动画转换:]_block_invoke 15 UIKitCore 0xcd458 +[UIView _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] 16 UIKitCore 0xa054c +[UIView(UIViewAnimationWithBlocks)animateWithDuration:延迟:选项:动画:完成:] 17 UIKitCore 0x2b1cdc -[UIViewControllerBuiltinTransitionViewAnimator animateTransition:] 18 UIKitCore 0x7fb8b4 ___UIViewControllerTransitioningRunCustomTransition_block_invoke_3 19 UIKitCore 0x2010d0 +[UIKeyboardSceneDelegate _pinInputViewsForKeyboardSceneDelegate:onBehalfOfResponder:duringBlock:] 20 UIKitCore 0x2b1864 ___UIViewControllerTransitioningRunCustomTransition_block_invoke_2 21 UIKitCore 0x1f2580 +[UIView(动画)_setAlongsideAnimations:toRunByEndOfBlock:] 22 UIKit 核心 0x1f243c _UIViewControllerTransitioningRunCustomTransition 23 UIKitCore 0x76430c __56-[UIPresentationController runTransitionForCurrentState]_block_invoke_3 24 UIKitCore 0x1a0430 -[_UIAfterCACommitBlock 运行] 25 UIKitCore 0x1a0364 -[_UIAfterCACommitQueue 刷新] 26 libdispatch.dylib 0x2320 _dispatch_call_block_and_release 27 libdispatch.dylib 0x3eac _dispatch_client_callout 28 libdispatch.dylib 0x126a4 _dispatch_main_queue_drain 29 libdispatch.dylib 0x122f4 _dispatch_main_queue_callback_4CF 30 核心基础 0x98d18 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE 31 核心基础 0x7a650 __CFRunLoopRun 32 核心基础 0x7f4dc CFRunLoopRunSpecific 33 图形服务 0x135c GSEventRunModal 34 UIKitCore 0x39d37c-[UIApplication_run] 35 UIKitCore 0x39cfe0 UIApplicationMain 36 eldman 0x1e234 main + 17 (AppDelegate.swift:17) 37 ??? 0x1da5c8dec(缺失)

我从 crashlytics 得到了这个崩溃报告,这只发生在 Ipad 上。我们如何修复 UIDatePicker 中的自动旋转? 我希望 UIViewControllers 的自动旋转能够像在我的应用程序中一样工作并且不能改变任何东西,而且我无法找到崩溃的控制器。 我也找不到有关 UIDatePickerContainerViewController 的任何信息。

我知道在 stackoverflow 上有几个关于自动旋转的类似问题,但我找不到任何关于 UIDatePicker Causing crash in iPad due to rotation 的有用信息。这是关于我的应用程序中的 UserInterfaceIdioms:

AppDelegate中的代码:

var orientationLock = UIInterfaceOrientationMask.portrait

func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
    return self.orientationLock
}

struct AppUtility {
    static func lockOrientation(_ orientation: UIInterfaceOrientationMask) {
        if let delegate = UIApplication.shared.delegate as? AppDelegate {
            delegate.orientationLock = orientation
        }
    }

    static func lockOrientation(_ orientation: UIInterfaceOrientationMask, andRotateTo rotateOrientation:UIInterfaceOrientation) {
        self.lockOrientation(orientation)
        UIDevice.current.setValue(rotateOrientation.rawValue, forKey: "orientation")
    }
}

整个应用程序只能在纵向模式下工作,在一个应该只能在横向模式下工作的视图控制器中,代码是:

 AppDelegate.AppUtility.lockOrientation(UIInterfaceOrientationMask.landscapeRight, andRotateTo: UIInterfaceOrientation.landscapeRight)

ios swift ipad uidatepicker shouldautorotate
© www.soinside.com 2019 - 2024. All rights reserved.