list - TableView 的索引列表显示点 iOS 5+

标签 list uitableview ios5 indexed

在我的应用程序中,我在带有索引列表的 TableView 中显示联系人。我正在显示索引列表如下:

 static NSString *letters = @"abcdefghijklmnopqrstuvwxyz#";

-(void)getAllUserInfoUsingBlock:(lclResultsArray) block
{
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
        NSMutableArray *allUserInfoArray = [[NSMutableArray alloc]init];
        NSLog(@"[letters length]:- %d",[letters length]);
        for (int i = 0; i < [letters length]; i++ ) {

            NSMutableDictionary *row = [[NSMutableDictionary alloc] init];

            char currentLetter[2] = { toupper([letters characterAtIndex:i]), '\0'};
            NSString *str=[NSString stringWithCString:currentLetter encoding:NSASCIIStringEncoding];
            NSMutableArray *words = nil;
            NSLog(@"Value of i:- %d:: Letter:- %@",i,str);
            if (i<[letters length]) {
                words = [self getUserInfoByStartingCharOfLastName:str isForEmptyValue:NO];
            }
            else {
                // Get users where name is empty
                words = [self getUserInfoByStartingCharOfLastName:@"" isForEmptyValue:YES];
            }

            NSLog(@"Count for %@ :- %d",str,words.count);
            [row setValue:str forKey:@"sectionTitle"];
            [row setValue:words forKey:@"sectionRows"];
            [allUserInfoArray addObject:row];

        }
        dispatch_async(dispatch_get_main_queue(), ^{
            for (NSDictionary *dict in allUserInfoArray) {
                NSLog(@"Array count:- %d",[[dict objectForKey:@"sectionRows"]count]);
            }
            block(allUserInfoArray,nil);
        });
    });
}

- (NSString *)tableView:(UITableView *)aTableView titleForHeaderInSection:(NSInteger)section 
{
    if (aTableView != self.searchDisplayController.searchResultsTableView){
        NSMutableDictionary *sections=[self.contactsArray objectAtIndex:section];
        NSString * sectionTitle= [sections objectForKey:@"sectionTitle"];
        return sectionTitle;
    }
    return nil;
}

- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index 
{
    if (tableView != self.searchDisplayController.searchResultsTableView){
        NSMutableDictionary *sections=[self.contactsArray objectAtIndex:index];
        NSString * sectionTitle= [sections objectForKey:@"sectionTitle"];
        return [self.indices indexOfObject:sectionTitle];
    }
    return 0;
}

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

    if (tableView != self.searchDisplayController.searchResultsTableView){
        return [self.contactsArray valueForKey:@"sectionTitle"];
    }
    return nil;
}

但是显示如下图

enter image description here

enter image description here

正如您在第一张图片中看到的那样,它显示的是 A.C.E .... V.X.Z# 它在每个字符后显示交替点 (.)。但如第二张图片所示,它正在显示来自 ABC....XYZ 的表格的正确标题#

我的实现有什么问题?

最佳答案

索引列表中字符之间的替代点取决于该索引列表的显示高度。如果我们可以增加 tableSize 。它​​将自动显示整个字符。

关于list - TableView 的索引列表显示点 iOS 5+,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13121929/

相关文章:

c# - 如何在 C# 中列出 %TEMP% 和 %USERNAME% 目录?

ios - 如何在 UITableView 中一次为多个单元格添加边框?

list - 可逆合并

python - 如何摆脱 python 列表中的列表?

ios - 以编程方式将按钮添加到 TableView 单元格

Xcode 6.1.1 将 TableView 更改为静态单元格时崩溃

ios - 以编程方式添加时模糊 UILabel

iOS 5.0 GLKit GLKTextureLoader- glBindTexture 发生在哪里?

ios - MapKit 中的 MapTypeStyle

Python:如何从键值字典列表构造元组值字典?