LeoNatan / LNPopupController

A framework for presenting view controllers as popups of other view controllers, much like the Apple Music and Podcasts apps.
MIT License
3.03k stars 339 forks source link

UISearchController keeps crashing UISearchController and UISearchBar after updating to the latest version #307

Closed darkForestCat closed 5 years ago

darkForestCat commented 5 years ago

I have updated to the latest version manually and after that when I click UISearchBar or UISearchController app keeps crashing. Tested on iOS 12.1 and 12.0. Latest and previous version of Xcode.

Here is the text of the error:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UICompatibilityInputViewController viewControllers]: unrecognized selector sent to instance 0x7fa22466d970' *** First throw call stack: ( 0 CoreFoundation 0x000000010cbc929b __exceptionPreprocess + 331 1 libobjc.A.dylib 0x000000010c133735 objc_exception_throw + 48 2 CoreFoundation 0x000000010cbe7fa4 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132 3 UIKitCore 0x0000000110963163 -[UIResponder doesNotRecognizeSelector:] + 287 4 CoreFoundation 0x000000010cbcdfb6 ___forwarding___ + 1446 5 CoreFoundation 0x000000010cbcfe88 _CF_forwarding_prep_0 + 120 6 LNPopupController 0x000000010c0e26a6 -[UISplitViewController(LNPopupSupportPrivate) _ln_addChildViewController:] + 70 7 UIKitCore 0x00000001102224de -[UICompatibilityInputViewController setInputMode:] + 994 8 UIKitCore 0x00000001103ff17f -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:] + 2133 9 UIKitCore 0x00000001109669b6 -[UIResponder(UIResponderInputViewAdditions) reloadInputViews] + 81 10 UIKitCore 0x00000001109cbf9c __45-[UISearchBarTextField _becomeFirstResponder]_block_invoke + 311 11 UIKitCore 0x00000001109cbe63 -[UISearchBarTextField _becomeFirstResponder] + 554 12 UIKitCore 0x00000001109625bb -[UIResponder becomeFirstResponder] + 699 13 UIKitCore 0x0000000110c7db52 -[UIView(Hierarchy) becomeFirstResponder] + 145 14 UIKitCore 0x0000000110b8d937 -[UITextField becomeFirstResponder] + 237 15 UIKitCore 0x0000000110be3283 -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) setFirstResponderIfNecessary] + 208 16 UIKitCore 0x0000000110c01519 -[UITextSelectionInteraction oneFingerTap:] + 3851 17 UIKitCore 0x00000001107798e9 -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] + 57 18 UIKitCore 0x00000001107827c7 _UIGestureRecognizerSendTargetActions + 109 19 UIKitCore 0x000000011077ffac _UIGestureRecognizerSendActions + 305 20 UIKitCore 0x000000011077f204 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 858 21 UIKitCore 0x0000000110770c88 _UIGestureEnvironmentUpdate + 1329 22 UIKitCore 0x0000000110770715 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 478 23 UIKitCore 0x0000000110770485 -[UIGestureEnvironment _updateForEvent:window:] + 200 24 UIKitCore 0x0000000110d91a1a -[UIWindow sendEvent:] + 4058 25 UIKitCore 0x0000000110597e10 -[UIApplication sendEvent:] + 352 26 UIKitCore 0x00000001104d00d0 __dispatchPreprocessedEventFromEventQueue + 3024 27 UIKitCore 0x00000001104d2cf2 __handleEventQueueInternal + 5948 28 CoreFoundation 0x000000010cb2cb31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 29 CoreFoundation 0x000000010cb2c3a3 __CFRunLoopDoSources0 + 243 30 CoreFoundation 0x000000010cb26a4f __CFRunLoopRun + 1263 31 CoreFoundation 0x000000010cb26221 CFRunLoopRunSpecific + 625 32 GraphicsServices 0x00000001137d61dd GSEventRunModal + 62 33 UIKitCore 0x000000011057c115 UIApplicationMain + 140 34 Free Music 0x00000001021f0b44 main + 68 35 libdyld.dylib 0x000000010df48551 start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException

LeoNatan commented 5 years ago

Could you please provide a demo project?

LeoNatan commented 5 years ago

v2.6.2

florianpreknya commented 5 years ago

I have the same problem, also, the same stack trace. The crash happens when I call UIViewController.addChild on a UIViewController instance (__lnaddChildViewController is called for any instance of UIViewController, not only for UISplitViewController instances).

You can reproduce the problem with the demo project, by adding the following lines

        let aChildCtrl = UIViewController()
        addChild(aChildCtrl)

in DemoAlbumTableViewController.viewDidLoad.

LeoNatan commented 5 years ago

This has been fixed.

florianpreknya commented 5 years ago

True. Thanks! 👍