3
votes

I've got a Master-Detail project using Xcode 7 beta 4 (Swift 2.1), where both the MVC and DVC are UIViewControllers. I have a UISearchController property in the DVC, which is used to display a UISearchBar in the titleView of the DVC nav controller. This search bar is working fine on iPad, but on iPhone, when I push the DVC, I can see the UISearchBar, but it cannot be tapped or first responder.

The odd thing is if I instantiate a local UISearchController in viewDidLoad and set its searchBar as the titleView, I can interact with the UISearchBar just fine, but every time I push the view controller, I get a warning:

"Attempting to load the view of a view controller while it is deallocating is not allowed - UISearchController"

If I create a class instance of the UISearchController by creating a DVC property, then the UISearchBar isn't interactable:

self.detailViewController?.navigationItem.titleView = self.searchController.searchBar

But if I do a local variable, it's interactable (with that warning stated above):

let localSearchController = UISearchController(searchResultsController: nil)
self.detailViewController?.navigationItem.titleView = localSearchController.searchBar

This bug has completely dumbfounded me, and it only occurs on iPhone. It seems like a simple problem, and I've tried many different approaches to figure it out. Maybe someone here has an idea what's wrong. Thanks!

1
did you ever manage to make it work? I'm in a similar situation except that I don't get any warningjbouaziz
No, I've yet to figure this one out. I'll have to tackle it soon :)powertoold
Got it, if you ever do I'd be really interested in seing how you made it work :)jbouaziz

1 Answers

1
votes

I was able to solve this issue by searching for definesPresentationContext in my app and deleting all the instances of it. I'm sure there may be a way to fix it without deleting.