2015-05-15 4 views
0

Когда я выбираю UITableViewCell и начинаю прокрутку до точки, где ячейки исчезают с экрана, разделители на этих ячейках исчезают, как только они появляются на экране.Отделители ячейки UITableView исчезают при выборе

Делегат:

- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    [self.tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone]; 
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 

    if(cell == nil){ 
     if(Type == Scene){ 
      Group *scene = [[appdata getScenes]objectAtIndex:lastRequestedPropertyPosition]; 
      [selectedArray addObject:scene.id]; 
     }else if(Type == Product){ 
      Device *device = [[appdata getDevices]objectAtIndex:lastRequestedPropertyPosition]; 
      [selectedArray addObject:device.id]; 
     } 
    }else{ 
     [selectedArray addObject:[NSNumber numberWithInt:cell.tag]]; 
    } 
} 

Datasource:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"protoCell" forIndexPath:indexPath]; 
    if (!cell) { 
     cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"protoCell"]; 
    } 
    Group *group = [[appdata getScenes] objectAtIndex:indexPath.row]; 
    if(group != nil){ 
     [cell.textLabel setText:group.name]; 
    } 

    cell.tag = group.id.intValue; 
    return cell; 
} 

Может кто-нибудь сказать, что пошло не так?

Благодаря

EDIT Используя это только делает сепаратор исчезают выбрать вместо того, чтобы просто держать там разделитель.

- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    [tableView deselectRowAtIndexPath:indexPath animated:YES]; 
    [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; 
    [self.tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone]; 
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 

    if(cell == nil){ 
     if(Type == Scene){ 
      Group *scene = [[appdata getScenes]objectAtIndex:lastRequestedPropertyPosition]; 
      [selectedArray addObject:scene.id]; 
     }else if(Type == Product){ 
      Device *device = [[appdata getDevices]objectAtIndex:lastRequestedPropertyPosition]; 
      [selectedArray addObject:device.id]; 
     } 
    }else{ 
     [selectedArray addObject:[NSNumber numberWithInt:cell.tag]]; 
    } 
} 
+0

эта ссылка может помочь у http://stackoverflow.com/questions/19212476/uitableview-separator-line-disappears-when-selecting-cells-in-ios7 –

ответ

0

Причиной моей проблемы было то, что я использовал синий оттенок цвета, чтобы показать выбранную ячейку. Однако этот оттенок был слишком большим. Он покрывал Seperator

0

В tableView:didSelectRowAtIndexPath, если вы пришлете оба сообщения ниже, проблема решена визуально (с вероятной стоимостью производительности).

[tableView deselectRowAtIndexPath:indexPath animated:YES]; 
[tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; 

Для этой работы (для меня), deselectRowAtIndexPath:animated: должен содержать animated:YES. Анимация, используемая для reloadRowsAtIndexPaths:withRowAnimation:, не имеет значения.

+0

Смотрите мой отредактированный код –

Смежные вопросы