ios - UITableView 单元格分隔符在被选中时消失

标签 ios objective-c uitableview separator

当我选择一个 UITableViewCell 并开始滚动到单元格从屏幕上消失的位置时,这些单元格上的分隔符会在它们重新出现在屏幕上时消失。

代表:

- (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]];
    }
}

数据源:

- (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;
}

谁能告诉我这里出了什么问题?

谢谢

编辑 使用它只会使分隔符在选择时消失,而不是仅仅将分隔符保留在那里。

- (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]];
    }
}

最佳答案

我的问题的原因是我使用蓝色阴影来显示被选中的单元格。然而这个阴影有点太大了。它覆盖了分隔符

关于ios - UITableView 单元格分隔符在被选中时消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30258452/

相关文章:

objective-c - 调用方法时ASIHTTPREQUEST框架编译错误/链接错误

ios - 显示下载进度的通知小部件

iphone - 在应用程序的下一个操作之前完成请求操作

ios - 带字符串的 Objective C 替代方法触发器名称

ios - watch 应用程序启动时出现错误 clientIdentifier for interfaceControllerID not found

ios - 带有 xcode 8 的 Alamofire 2.0

ios - 即使隐藏 iOS7 状态栏,也允许单次滑动显示通知和控制中心

swift - TableView Cell 的高度不会根据 WebView 动态变化

ios - 如何将 Javascript 日期转换为 iOS 日期格式

iphone - 从 uitableviewcell 访问 uitableviewcontroller