fer*_*ris 54 objective-c uitableview ios ios8
tableViewHeader我UITableView在iOS 8中遇到了一个奇怪的错误.当在一个单元格上滑动以显示删除按钮(标准iOS滑动到删除)时,它会tableViewHeader随着正在滑动的单元格一起移动.当我轻扫单元格时,标题的移动方式与刷过单元格的方式相同.表视图中没有其他单元格被移动,只有标题和任何单元格被刷过.我在iOS 7上测试过这个没有遇到过这个问题.对我来说,这似乎是tableViewHeaderiOS 8中的一个错误,因为它只出现在这个版本中,似乎永远不会发生.我认为没有理由将标题包含在swipe-to-delete中.
下面只是一个模型.在应用程序中滑动删除是默认的iOS,没有自定义.

Bra*_*d C 49
基于ferris的答案,我发现使用UITableViewCell作为节头时最简单的方法是返回viewForHeaderInSection中单元格的contentView.代码如下:
override func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let cell : cellSectionHeader = tableView.dequeueReusableCellWithIdentifier("SectionHeader") as cellSectionHeader
return cell.contentView
//cellSectionHeader is my subclassed UITableViewCell
}
Run Code Online (Sandbox Code Playgroud)
fer*_*ris 25
这是因为我使用UITableViewCell作为表的标题.要解决滑动问题,而不是使用tableView.tableHeaderView = cell,我使用以下内容:
UIView *cellView = [[UIView alloc] init];
[cellView addSubview:cell];
tableView.tableHeaderView = cellView
Run Code Online (Sandbox Code Playgroud)
我不知道为什么这会解决问题,特别是它在iOS 7上运行,但它似乎解决了这个问题.
确保将所有视图添加到单元格视图,如单元格contentView所示,否则按钮将不响应.
作品:
[cell addSubview:view]; 要么 [self addSubview:view];
不起作用:
[cell.contentView addSubview:view] 要么 [self.contentView addSubview:view]
避免标题随单元格移动的方法是返回viewForHeaderInSection中单元格的contentView.如果你有一个名为SectionHeaderTableViewCell的子类UITableViewCell,这是正确的代码:
-(UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
SectionHeaderTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SectionHeader"];
//Do stuff to configure your cell
return cell.contentView;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7921 次 |
| 最近记录: |