【问题标题】:How to set UITableViewCellSeparatorStyleNone in tableview?如何在 tableview 中设置 UITableViewCellSeparatorStyleNone?
【发布时间】:2016-02-04 16:26:44
【问题描述】:

当我将UITableViewCellSeparatorStyleNone 设置为tableView 时,分隔视图仍然可见吗?

我设置了tableview的属性,

self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

在视图调试中,我仍然在我的单元格中找到了一个 UITableViewCellSeparatorView, 如何删除分隔符视图?

【问题讨论】:

  • 所有单元格下方都是分隔符吗?
  • 你在 xcode 属性检查器中为 Seperator 属性设置了 none 吗?
  • 是的,我从 Xcode 属性检查器中设置了 none,解决问题

标签: ios objective-c iphone xcode


【解决方案1】:

您可以在 storyboard 的 tableview 中设置 UITableViewCellSeparatorStyleNone。 在这里我附上屏幕截图以进行更多说明。

【讨论】:

    【解决方案2】:

    因为单元格在呈现时被重用(使用 dequeueReusableCellWithIdentifier):您必须为该单元格使用不同的标识符。我也为它制作了一个自定义 UITableViewCell 子类。

    这是一个代码,其中我的最后一个单元格是一个特殊的单元格,它将加载 X 多个单元格..

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
        if (indexPath.row == lastIndex) {
            LoadingNextCellView *cell = [tableView dequeueReusableCellWithIdentifier:@"LoadingNextCell"];
            if (cell == nil) {
                cell = [[LoadingNextCellView alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"LoadingNextCell"];
            }
            cell.indexPath = indexPath;
            cell.titleLabel.text = [NSString stringWithFormat:@"Loading next %d trees..",PRELOAD_TREES];
            return cell;
        } else {
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
            if (cell == nil) {
                cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
            }
         }
         return cell; 
    }
    

    根据此逻辑自定义您的单元格。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多