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
UITableView
class toSearchTableView
in storyBoard. - Make an
@IBOutlet
ofSearchTableView
in your viewController - Conform to
searchDataSource
protocol - Create model object, subclass of
NSObject
- Assign array of model objects in
itemList
- Return
itemList.count
from numberOfRowsInSection - Implement
searchPropertyName()
ofSearchTableViewDataSource
protocol - return model object's
property
name 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