在iOS 11上,如果表格视图样式设置为普通(而不是分组),则单元格编辑操作或滑动操作(仅适用于iOS 11)将显示在节标题的顶部。这似乎是默认功能,我想知道这是系统错误还是我的实现有误。
我使用了默认表格视图实现和以下功能来实现标题和编辑操作行: 标题名称:
这是编辑操作的屏幕截图:
这种情况只会在iOS 11上发生。我已经尝试交替使用上述两种方法,但结果相同。
你有什么想法可以解决这个问题吗?这是iOS 11系统的一个bug吗?
我使用了默认表格视图实现和以下功能来实现标题和编辑操作行: 标题名称:
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return "Section \(section)"
}
编辑行的操作:
override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
let firstAction = UITableViewRowAction(style: .normal, title: "Action1", handler: {_,_ in })
let secondAction = UITableViewRowAction(style: .destructive, title: "Action2", handler: {_,_ in })
return [firstAction, secondAction]
}
滑动删除操作(只适用于iOS 11的新实现):
override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let action1 = UIContextualAction(style: .normal, title: "Action1", handler: {_,_,_ in })
let action2 = UIContextualAction(style: .destructive, title: "Action2", handler: {_,_,_ in })
return UISwipeActionsConfiguration(actions: [action1, action2])
}
这是编辑操作的屏幕截图:
![Edit action overlapping section header](https://istack.dev59.com/5Brlw.webp)
你有什么想法可以解决这个问题吗?这是iOS 11系统的一个bug吗?