天天看点

iOS中 UISearchController 搜索栏 UI技术分享

懒加载及释放

调用:

初始化SearchController初始化

//引入UISearchController之后, UITableView的内容也要做相应地变动: 即cell中要呈现的内容是items, 还是searchResults.这一点, 可以通过UISearchController的active属性来判断, 即判断输入框是否处于active状态.

//UITableView相关的很多方法都要根据active来做判断:

配置导航条

#pragma mark 协议中的方法

#pragma mark - Table view data source

返回cell:

业务代理返回高:

最终效果:

iOS中 UISearchController 搜索栏 UI技术分享