gpt4 book ai didi

ios - 为什么滑动单元格时表格 View 单元格中的 View 会困惑?

转载 作者:行者123 更新时间:2023-11-29 05:52:04 25 4
gpt4 key购买 nike

我正在为 TableView 的单元格设置滑动操作。当我在这个单元格中滑动单元格 View 时,它变得困惑,我检查了标签 View 和 ImageView 的约束。

这是我的问题的 gif 图像: https://ibb.co/SwwfYMB

这是我的细胞约束的照片 my constraint of cell

这是我的代码

 // MARK: delete Action
func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
return true
}
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {

let itemREF = arrayItems[indexPath.row].itemId
let imageREF = arrayItems[indexPath.row].Image

let storage = Storage.storage()
let storageRef = storage.reference(forURL: imageREF!)
storageRef.delete { error in
if let error = error {
print(error)
} else {
// File deleted successfully
}
}

Database.database().reference().child("Items").child(itemREF!).removeValue()

arrayItems.remove(at: indexPath.row)
let deleteIndex = [indexPath]
tableView.deleteRows(at: deleteIndex, with: .automatic)
// self.myTableView.deleteRows(at: [indexPath], with: .fade)
self.myTableView.reloadData()
}

最佳答案

it seems that problem with you image view you can use UIStackview like 
<UIStackView>
<orientation>horizontal>
<FirstView/>
<ImageView>
</UIStackView>
this is for example how stackview will manage also set constraints accordingly leading and trailing.

关于ios - 为什么滑动单元格时表格 View 单元格中的 View 会困惑?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55571845/

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