2012-10-29 39 views
2

在我的應用程序中,我使用索引列表在表格視圖中顯示聯繫人。我顯示索引列表如下:表格視圖的索引列表顯示點iOS 5+

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

如圖正如你在第一圖像顯示其ACE看... 。VXZ#它在每個字符之後顯示交替點(。)。但是如第二張圖所示,它顯示ABC的表格顯示正確的headet標題.... XYZ#

我的實現有什麼問題?

回答

4

索引列表中字符之間的替代點取決於索引列表的顯示高度。如果我們可以增加tableSize,它將自動顯示整個字符。

+0

謝謝。增加高度後,它會顯示所有索引列表。 – iOSAppDev

+1

如果我不能在我的視圖中增加桌面高度,該怎麼辦?如何滾動表格視圖右側的索引字符? –

+0

有人有這個答案嗎? –