我正在尝试在UISearchBar
中实现UITableView
,其行为与iPod应用程序的“艺术家”标签中的行为类似。
我隐藏了导航栏,并调整了搜索框的大小以显示“取消”按钮等,但我无法隐藏部分索引标题。
- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar
{
inSearchMode_ = YES; // tell sectionIndexTitlesForTableView: to return nil
tableView_.scrollEnabled = NO; // works correctly, var is definitely wired
[tableView_ reloadSectionIndexTitles]; // doesn't call sectionIndexTitlesForTableView:
...
我错过了什么吗? UITableView -reloadSectionIndexTitles
被打破了吗?
通常我对此类事情的回应是致电reloadData
,但这会产生导致UISearchBar
失去焦点的副作用。
答案 0 :(得分:1)
我认为你想要的方法是沿着这些方向(假设你有一个你想要搜索的ArtistController):
这将使您免于操纵原始控制器/导航栏并使其具有更好的可用性
答案 1 :(得分:0)
我似乎需要做的是使用UISearchDisplayController
而不是自己动手。我能够修改“TableSearch”示例以使用节和节标题,它的行为与我想要的一样。