0
的時候,這裏是我的代碼表視圖細胞開始搖晃試圖滑動刪除當前單元
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
print("editingStyle")
if editingStyle == .delete {
//Doing my task
}
}
我每次向左滑動,其他細胞開始搖晃,並創建一個非常糟糕的用戶體驗。 我已經嘗試了一些黑客喜歡
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) ->UITableViewCell {
if let cell = tableView.dequeueReusableCell(withIdentifier: kCellReuseCardIdentifier) as? MyCustomTableViewCell {
let frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width - 16, height: 125)
cell.frame = frame
cell.contentView.frame = frame
// Cells get squished when editing mode is enabled. To prevent that from happening , we create a dummy cell
let dummyCell = tableView.dequeueReusableCell(withIdentifier: kDummyCellIdentifier) as! DummySpaceTableViewCell
dummyCell.addSubview(cell.contentView)
dummyCell.clipsToBounds = true
return dummyCell
}
有趣的是,這個hack作品的iOS測試版11。在iOS 10中,這會導致單元晃動問題。請注意,我的tableView有n部分,每個部分有行。請幫忙。