粉紅色被賦予單元格的內容視圖。單元格下移到右側單元格滑動刪除UITableView
雖然通過刷卡刪除電池使用委託commitEditingStyle
刪除僅刪除刪除單元格下方的單元之後被轉移到右側
我沒有得到任何有關的想法那爲細胞留下了餘量。 滾動並返回到放錯位置的單元格時,佈局正確並且該邊距被移除。
我在Xcode 8.0中使用了Swift。
下面是代碼:
func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if (editingStyle == UITableViewCellEditingStyle.Delete) {
// handle delete (by removing the data from your array and updating the tableview)
let date = dateKeys[indexPath.section]
var notificationObject = dataSection[date] as! [Notification]
let deleteNotificationId = notificationObject[indexPath.row].notifId
for notifObject in self.notificationArray {
if notifObject.notifId == deleteNotificationId {
if let index = self.notificationArray.indexOf(notifObject) {
self.notificationArray.removeAtIndex(index)
self.dataSection = self.categorizeNotification(self.notificationArray)
self.dateKeys = self.sortArrayDate()
self.notificationTable.reloadData()
break
}
}
}
}
}
我在刪除「commitEditingStyle」函數中的數組中的項後重新加載表。 –
在這裏發佈您的commitEditingStyle代碼。 – KAR
在此處提及帶有屏幕截圖的代碼。 – KKRocks