简体   繁体   English

UITableView节索引没有响应

[英]UITableView Section Index doesn't respond

I have a table view which has section indexes enabled. 我有一个已启用部分索引的表视图。 All the indexes are showing properly, however I can't get the search icon to actually respond. 所有索引均显示正确,但是我无法使搜索图标真正响应。 The picture on the left shows as high as the table will scroll after using the section index scroll bar on the right, but it should show up with the right hand side design. 使用右侧的区域索引滚动条后,左侧的图片显示的表格与表格的滚动程度一样高,但应使用右侧的设计显示。 Any help would be much appreciated!! 任何帮助将非常感激!!

左侧显示了当我滚动浏览部分索引时发生的情况。它在A处停止,但我希望搜索图标导致表格视图滚动到顶部

I've always done custom scrolling for the search bar in this case and returned -1 from the delegate method. 在这种情况下,我总是对搜索栏进行自定义滚动,并从委托方法中返回-1。

My tableView:sectionForSectionIndexTitle:atIndex: looks like this - not sure if there's a better way, though: 我的tableView:sectionForSectionIndexTitle:atIndex:看起来像这样-不确定是否有更好的方法:

- (NSInteger)tableView:(UITableView *)tv sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index {
    NSInteger section = -1;
    if ([title isEqualToString:UITableViewIndexSearch]) {
        CGRect searchBarFrame = self.searchDisplayController.searchBar.frame;
        [tv scrollRectToVisible:searchBarFrame animated:NO];
    }
    else {
        section = whatever logic you use to determine section
    }
    return section;
}

BTW, this is using a the searchDisplayController property. 顺便说一句,这是使用searchDisplayController属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM