UISearchBar in a UITableView

后端 未结 2 1909
鱼传尺愫
鱼传尺愫 2021-02-06 17:00

I\'m trying to mimic the behaviour of a table view similar to the iPod app for Artists - it\'s a sectioned table view with a section index on the right, with a search bar at the

2条回答
  •  广开言路
    2021-02-06 17:57

    Put the search Controller in the beginning of the tableView and try this:

    - (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index {
        if (index==0){
            [tableView scrollRectToVisible:CGRectMake(0,0,1,1) animated:NO];
            return -1;
        }
    ...
    }
    
    
    - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
            NSMutableArray * retValue =[NSMutableArray arrayWithArray:[YOUR ARRAY]];
            [retValue insertObject:UITableViewIndexSearch atIndex:0];
           return retValue;
     } 
    

提交回复
热议问题