0

- Supported orientations has no common orientation with the application, and [_UIDatePickerContainerViewController shouldAutorotate] is returning YES

Fatal Exception: 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(Internal) _didMoveFromWindow:toWindow:] 8 UIKitCore 0xd0b68 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke 9 CoreAutoLayout 0x4fcc -[NSISEngine withBehaviors:performModifications:] 10 UIKitCore 0x105c200 -[UIView _postMovedFromSuperview:] 11 UIKitCore 0x1e8b8 -[UIView(Internal) _addSubview:positioned:relativeTo:] 12 UIKitCore 0x3d9988 __67-[UIViewControllerBuiltinTransitionViewAnimator animateTransition:]_block_invoke_2 13 UIKitCore 0x30f58 +[UIView(Animation) performWithoutAnimation:] 14 UIKitCore 0x3c0bac __67-[UIViewControllerBuiltinTransitionViewAnimator animateTransition:]_block_invoke 15 UIKitCore 0xcd458 +[UIView _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] 16 UIKitCore 0xa054c +[UIView(UIViewAnimationWithBlocks) animateWithDuration:delay:options:animations:completion:] 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(Animation) _setAlongsideAnimations:toRunByEndOfBlock:] 22 UIKitCore 0x1f243c _UIViewControllerTransitioningRunCustomTransition 23 UIKitCore 0x76430c __56-[UIPresentationController runTransitionForCurrentState]_block_invoke_3 24 UIKitCore 0x1a0430 -[_UIAfterCACommitBlock run] 25 UIKitCore 0x1a0364 -[_UIAfterCACommitQueue flush] 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 CoreFoundation 0x98d18 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE 31 CoreFoundation 0x7a650 __CFRunLoopRun 32 CoreFoundation 0x7f4dc CFRunLoopRunSpecific 33 GraphicsServices 0x135c GSEventRunModal 34 UIKitCore 0x39d37c -[UIApplication _run] 35 UIKitCore 0x39cfe0 UIApplicationMain 36 eldman 0x1e234 main + 17 (AppDelegate.swift:17) 37 ??? 0x1da5c8dec (Missing)

I got this crash report from crashlytics, this is happening for Ipad Only. How can we fix the autoRotation in UIDatePicker? I want the autorotation of UIViewControllers to work as it is in my application and can't change anything, Also i am not able to find the controller where it is crashing. I am, also not able to find anything about UIDatePickerContainerViewController.

I know there are several similar questions on stackoverflow about autorotation but i am not able to find anything useful about UIDatePicker Causing crash in iPad due to rotation. This is about UserInterfaceIdioms in my application: enter image description here

The code in 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")
    }
}

Whole application works in portrait mode only, In just one view controller which is supposed to work in landscape only, the code is : AppDelegate.AppUtility.lockOrientation(UIInterfaceOrientationMask.landscapeRight, andRotateTo: UIInterfaceOrientation.landscapeRight)

Vikas Saini
  • 483
  • 4
  • 16

0 Answers0