うちのいぬ Tech Blog

Tech Blog of Uchinoinu/My dog

Calling and configuring UISearchController in viewWillAppear to implement Search View, SearchBar layout became bad

Environment

What's happened?

f:id:susanne:20160907120904g:plain

Collapsed layout of SearchBar

Search View

f:id:susanne:20160907105110p:plain

Input text in SearchBar

f:id:susanne:20160907105117p:plain

Search Result

f:id:susanne:20160907105134p:plain

Search Target Data can be divided to some layer, so use section and side index list to show them in TableView

Goes to detail page by tapping result cell and tapping back button of NavigationBar....

f:id:susanne:20160907105138p:plain

Width of SearchBar get small of size of width of side index list

And try to search again...

f:id:susanne:20160907105144p:plain

omg....

How to Overcome?

Problems

  • Called and Configured UISearchController in viewWillAppear
    • Search result data is not deleted when backed from detail page after searching. And Configure UISearchController in view will appear

Improve

  • Want to keep search result data and search word showed unless user intentionally delete them
    • So Call UISearchController in viewDidLoad

Result

f:id:susanne:20160907120918g:plain

Not so bad....