【问题标题】:UITableView Header and footer indent during edit modeUITableView页眉和页脚在编辑模式下缩进
【发布时间】:2015-01-05 22:50:03
【问题描述】:

我在情节提要中有一个带有三个单元格原型的 UITableView,我在页眉部分使用一个单元格,一个用于普通表格行,另一个用于表格页脚。

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    static NSString *CellIdentifier = @"Header";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    //some personalization
    return cell;
}

我的问题是每当我进入表格视图的编辑模式时,页眉和页脚都会向左移动,就像当前正在编辑的单元格一样。

- (void) setEditing:(BOOL)editing animated:(BOOL)animated {
    [super setEditing:editing animated:animated];
    [self.tableView setEditing:editing animated:animated];
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{
    return YES;
}

在编辑模式下:

任何解决方案或提示? 上次 XCode 更新都没有修复它。

谢谢

【问题讨论】:

  • 我发布了关于如何创建标题和激活编辑模式的代码。
  • 你改变了动画还是调整了框架?希望更详细。
  • 没有别的了。问题可能是我使用 UITableViewCell 作为 Header 而不是 UIView?

标签: ios objective-c xcode uitableview


【解决方案1】:

解决了。基本上我必须创建一个 UIView 并将其用作我的页眉/页脚,而不是使用 UITableViewCell。

感谢

Table Header Views in StoryBoards

Stick UITableView header view to top when creating header in storyboard

【讨论】:

    【解决方案2】:

    我解决了“移动”标题的问题,方法是使用 UIView 而不是 UITableViewCell 创建标题。您可以通过简单地将 UIView 拖出到 UITableView 来做到这一点,它将把它放在原型单元格的正上方/之间。然后您可以将其视为并在 Interface Builder 中查看。您可以为它创建一个控制器,但恕我直言,给它一个tag 然后使用tableView.viewWithTag(tag) 会更快更容易。希望对您有所帮助!

    【讨论】:

      【解决方案3】:

      一路上我发现使用tableViewCell 完全没问题,您只需返回单元格contentView 并且编辑时标题的缩进消失了。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-07-24
        • 1970-01-01
        • 2012-04-24
        • 1970-01-01
        • 2022-01-15
        • 2015-06-04
        • 1970-01-01
        相关资源
        最近更新 更多