- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我在 TableViewController 的标题中添加了一个搜索栏,并且还在“sectionIndexTitlesForTableView”数组中添加了一个“{search}”。现在在右侧,我得到了字母表中的字母 + 顶部的搜索符号...滚动到字母的部分(不是搜索字段)我使用了这个:
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index{
return index -1;
}
现在,当我单击字母 A 时,它会滚动到 A 部分,依此类推。只是我不能让“搜索符号”滚动到 tableView 标题中的搜索栏...
我该怎么做?
提前致谢...
最佳答案
如果搜索栏位于 tableView 的最顶部,您可以执行以下操作-
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index{
// as the search icon is at index 0, scroll to the top
if(index == 0)
[tableView scrollRectToVisible:CGRectMake(0, 0, searchBar.width, searchBar.height) animated:YES];
return index -1;
}
否则,如果它是一个没有任何行的部分,您可以这样做-
CGRect searchBarRect = [tableView rectForSection:searchBarIndex];
[tableView scrollRectToVisible:searchBarRect animated:YES];
HTH,
阿克谢
关于iphone - 使用 "tableView:sectionForSectionIndexTitle:atIndex:"帮助滚动到 TableViewHeader?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6994480/
我有一个带有 sectionIndexTitles 的 UITableView。这是我的数据源: let sSectionTitles = ["A","B","C","D","E","F","G","
我有一个包含完整字母表的部分索引 - 然而,我表格中的部分仅包含几个字母(例如 C、F、N、U)。 我想修改 sectionForSectionIndexTitle 以在将手指滑过部分索引时正确显示正
文档对此并不太清楚。为什么要求 UITableViewDataSource 提供索引栏部分标题的部分索引? 我的意思是...什么用例使该方法变得重要?什么时候调用它以及为什么? 最佳答案 基本上,它定
我刚开始使用 ios,我被 UITableView 困住了。 我想在 View 的右侧实现索引栏。我已经实现了这个但是当我点击索引栏上的部分时它不起作用。 这是我的代码。这里 indexArray 是
我想允许通过点击 UITableView 一侧的 sectionIndexTitles 来滚动我的 UITableView。到目前为止,我的解决方案如下: - (NSInteger)tableView
由于我是 Swift 的新手,所以我陷入了困境。我正在开发一个应用程序,我想在其中显示侧面索引部分,就像在联系人应用程序中一样。我在我的应用程序中使用了此代码 func tableView(_ tab
我正在尝试索引我的 UITableView使用以下代码 在我的 ViewDidLoad arrayOfTableView = [[NSArray alloc] initWithObjects:@"1"
嘿,有什么巧妙的方法可以使用部分索引跳转到表页眉或页脚吗?我想要的是在索引顶部添加一个部分索引,跳转到页眉,在底部添加另一个部分索引,无需滚动即可跳转到页脚。 有什么想法吗? 最佳答案 我将在 UIT
我在 TableViewController 的标题中添加了一个搜索栏,并且还在“sectionIndexTitlesForTableView”数组中添加了一个“{search}”。现在在右侧,我得到
我的 UITableView 中有数百个部分。我已将所有部分放在一个数组中,并将该数组更改为仅包含大写字母并删除了所有重复字符。 //sample array let sectionsArray: [
我在项目中使用了联系簿,所有数据显示为 sectionWise。Tableview 部分索引不显示该实现 sectionForSectionIndexTitle 和 sectionIndexTitle
我是一名优秀的程序员,十分优秀!