UITableView search bar?

天大地大妈咪最大 提交于 2019-12-04 19:57:05

Check out UISearchDisplayController. It handles the repositioning of the search bar, the graying of the screen, etc, etc, etc.

UIViewController has a UISearchDisplayController property, so it's pretty easy to hook up. There's also the TableSearch sample code.

This adds a search bar to a table view as the header view. This means that it scrolls with the table view:

- (void) viewDidLoad
{
    [super viewDidLoad];
    UISearchBar* searchBar = [[UISearchBar alloc] initWithFrame: CGRectMake(0, 0, 320, 45)];
    if (searchBar != nil) {
        // Your UISearchBar specifics here
        self.tableView.tableHeaderView = searchBar;
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!