简体   繁体   English

UITableView点击索引不会滚动到该部分

[英]UITableView tapping index doesnt scroll to section

I have a tableView where I have implemented section headers and I have the section titles appearing along the right hand side. 我有一个tableView,其中实现了节标题,并且节标题出现在右侧。 However, when I tap the index it doesn't scroll to that section even though I can see in my logs that it is returning the correct section. 但是,当我点击索引时,即使我在日志中看到它返回了正确的部分,它也不会滚动到该部分。

Here is my method for tableView:sectionForSectionIndexTitles:atIndex 这是我的tableView:sectionForSectionIndexTitles:atIndex方法

- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index {

NSLog(@"Title: %@", title);
NSLog(@"index: %d", index);

return [[UILocalizedIndexedCollation currentCollation] sectionForSectionIndexTitleAtIndex:index];
}

Any help would be great, thanks. 任何帮助将是巨大的,谢谢。

If you want to create alphabets scroll. 如果要创建字母,请滚动。 This will helps. 这会有所帮助。

-(void)viewDidLoad {

 //section index in tableview
    alphabetsArray = [[NSArray alloc] initWithObjects:@"#",@"A",@"B",@"C",@"D",@"E",@"F",@"G",@"H",@"I",@"J",@"K",@"L",@"M",@"N",@"O",@"P",@"Q",@"R",@"S",@"T",@"U",@"V",@"W",@"X",@"Y",@"Z", nil];

}

-(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{

 return alphabetsArray;

}

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

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