Search code examples
iosiphoneuitableviewuisearchdisplaycontroller

Uisearch bar ready on viewwillappear


When my modal view appears it looks like this (ui search bar and empty table). Very typical.

enter image description here

I want my view when it appears to look like this

enter image description here

How can I do it?


Solution

  • You could call [self.mySearchBar becomeFirstResponder] (Objective C) or mySearchBar.becomeFirstResponder() (Swift) in your viewWillAppear lifecycle method.