gpt4 book ai didi

ios - 滑动 UITableViewRowActions 时意外出现分隔线

转载 作者:可可西里 更新时间:2023-11-01 01:00:12 25 4
gpt4 key购买 nike

在我的应用程序中,我使用了一个 UITableView,它由多个标题和每个标题的一到两行组成。每个单元格都有两个 UITableViewRowActions。我的问题是,每当这些行操作被动画化时,单元格和下面的标题之间就会出现一个奇怪的分隔符。

我试过关闭默认分隔符,改用自定义分隔符,但出于某种原因,我实际上需要使用默认分隔符。

在下一步中,我尝试只为位于下一个标题顶部的那些单元格禁用分隔符,就像这样,但它不起作用:

if #available(iOS 9.0, *) {

tableView.cellLayoutMarginsFollowReadableWidth = false

}

cell.layoutMargins = UIEdgeInsetsZero
cell.preservesSuperviewLayoutMargins = false
cell.separatorInset.left = self.view.frame.size.width

为了帮助您对该问题有一个印象,我创建了三个显示奇怪行为的屏幕截图:

之前:

enter image description here

显示行操作时:

enter image description here

使用 tableView.setEditing(false, animated: true) 取消行操作后:

enter image description here

你知道如何删除这个奇怪的分隔线吗?

最佳答案

我终于找到了一个相对干净的解决方案来解决这个问题 - 我只是向每个标题 View 添加一个“行修复” View ,它将覆盖奇怪的分隔符。由于这似乎是一个 Apple 错误,这可能是最好的解决方法。

代码如下:

override func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {

let view = UITableViewHeaderFooterView()

let lineFix = UIView(frame: CGRect(x: 0, y: -0.5, width: tableView.frame.size.height, height: 0.5))
lineFix.backgroundColor = UIColor.groupTableViewBackgroundColor()
view.addSubview(lineFix)

return view

}

关于ios - 滑动 UITableViewRowActions 时意外出现分隔线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35186710/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com