2013-10-25 10 views
7

テーブルインデックスを設定しようとしていますが、右側に白いバーとして表示されています。私はストーリーボードを使用しています。誰が何が起こっているか知っていますか?おかげiOS7テーブルインデックスが白いバーとして表示される

コード:

#pragma mark - Tableview datasource 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
    // Return the number of sections in a tableview 
    return self.arrayOfCharacters.count; 
} 

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    // Return the height of each cell 
    return 55; 
} 

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView 
{ 
    // Return table index 
    return [NSArray arrayWithArray: [@"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|#" componentsSeparatedByString:@"|"]]; 
} 

- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index 
{ 
    // Match the section titls with the sections 
    NSInteger count = 0; 

    // Loop through the array of characters 
    for (NSString *character in self.arrayOfCharacters) { 

     if ([character isEqualToString:title]) { 
      return count; 
     } 
     count ++; 
    } 
    return 0; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    // Return the number of rows in the each section 
    return [[self.objectsForCharacters objectForKey:[self.arrayOfCharacters objectAtIndex:section]] count]; 
} 

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section 
{ 
    // Return the title for each section 
    return [NSString stringWithFormat:@"%@", [self.arrayOfCharacters objectAtIndex:section]]; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *cellIdentifier = @"preplanCell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 

    if (cell == nil) { 

     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; 
    } 

    // Create a pointer to our preplan 
    LBPrePlan *preplan = [[self.objectsForCharacters objectForKey:[self.arrayOfCharacters objectAtIndex:indexPath.section]] objectAtIndex:indexPath.row]; 

    cell.textLabel.text = preplan.name; 
    cell.detailTextLabel.text = preplan.address; 

    return cell; 
} 

答えて

11

私の問題を発見しました。 iOS7ではsectionIndexBackgroundColorを設定できます。それは全時間働いていたことが分かります。

6

次のコード

[[UITableView appearance] setSectionIndexBackgroundColor:[UIColor clearColor]]; 
    [[UITableView appearance] setSectionIndexTrackingBackgroundColor:[UIColor lightGrayColor]]; 
    [[UITableView appearance] setSectionIndexColor:[UIColor darkGrayColor]]; 
を使用してios7でテーブルビューのindexsetの背景色を変更することができます
関連する問題