UITableView subclass to easily search on tableView. Example project included.
- At first searchBar will be hidded. As user drag tableVeiw down, s/he'll see the the searchBar.
- Orientation support
Just drag and drop SearchTableView.swift file in your project
Steps:
- Change
UITableViewclass toSearchTableViewin storyBoard. - Make an
@IBOutletofSearchTableViewin your viewController - Conform to
searchDataSourceprotocol - Create model object, subclass of
NSObject - Assign array of model objects in
itemList - Return
itemList.countfrom numberOfRowsInSection - Implement
searchPropertyName()ofSearchTableViewDataSourceprotocol - return model object's
propertyname you want to search for.
There is an issue of searchBar overlaps statusBar. Steps to reproduce this issue:
- Users search
- Tap on any search result
- Navigate to another viewController
- Then change device orientation
- Back
This could be an apple bug. Apple sample code also has this issue
https://developer.apple.com/library/ios/samplecode/TableSearch_UISearchController/Introduction/Intro.html
