大佬教程收集整理的这篇文章主要介绍了UITableView iOS中的sectionForSectionIndexTitle,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我想在视图的右侧实现索引栏.我已经实现了这个,但当我点击索引栏上的部分时,它无法正常工作.
这是我的代码.这里indexArray是“A-Z”元素,finalArray是我的UITableView可变数组.
请告诉我应该在sectionForSectionIndextitle中实现什么.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return [finalArray count]; } - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection: (NSInteger)section { return [finalArray objectATindex:section]; } - (NSArray *)sectionIndextitlesForTableView:(UITableView *)tableView { return indexArray; } - (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndextitle: (NSString *)title aTindex:(NSInteger)index { }
假设您有一个包含4个项目的表格视图:
section index - 0 section title - 'A' items: ['Apple','Ant'] section index - 1 section title - 'C' items: ['Car','Cat']
然后你有26个部分索引标题(表视图右侧的索引):A – Z.
现在,用户点击字母’C’即可接听电话
tableView:sectionForSectionIndextitle:@"C" aTindex:2
您需要返回1 – “C”部分的部分索引.
如果用户点击’Z’,您还必须返回1,因为您只有2个部分,C最接近Z.
在简单的情况下,您在表视图中具有相同的部分,因为右侧的索引可以执行此操作:
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndextitle:(NSString *)title aTindex:(NSInteger)index { return index; }
NSInteger section = [_sectiontitles indexOfObject@R_625_6964@]; if (section == NsnotFound) // Handle missing section (e.g. return the nearest section to it?)
以上是大佬教程为你收集整理的UITableView iOS中的sectionForSectionIndexTitle全部内容,希望文章能够帮你解决UITableView iOS中的sectionForSectionIndexTitle所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。