我正在为表格视图的单元格设置滑动操作。当我在该单元格中滑动单元格视图时,它变得混乱,并且检查了标签Views和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()
}
答案 0 :(得分:0)
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.