If you're like me and needed the searchController to remain active while presenting modally another controller, then do the following to get the same effect of presenting modally without doing so directly:
Quick note: Not familiar enough with Obj-C to give an answer in that, but here's an answer in Swift 4. Someone feel free to edit and add Obj-C if necessary, but I think it's clear here how to solve the issue at-hand, even if it is in Swift.
Let's say I have a menu that I want to pop-up:
let info = the info you need to pass
let currVC = self.getTopMostViewController()
let menuVC = currVC.storyboard?.instantiateViewController(withIdentifier: "myStringIdentifierSetInStoryboard") as? EventMenuViewController
guard menuVC != nil else { return }
menuVC!.info = info // Pass info necessary (i.e. what you would normally pass in prepare(for segue: ...). menuVC.info is a global variable from your class
currVC.present(menuVC!, animated: true, completion: nil)
The implementation of getTopMostViewController() may vary. Mine is below and is adapted from here.
func getTopMostViewController() -> UIViewController {
let anyVC = UIViewController()
if var topController = UIApplication.shared.keyWindow?.rootViewController {
while let presentedViewController = topController.presentedViewController {
topController = presentedViewController
}
return topController
}
return anyVC
}
Hope this helps! This does not give you the error described for iOS 12 and Swift 4, although I did get that exact error when trying to present modally with an active search controller, which is what led me here.