2015-03-08 13 views
0

刪除UITableView中的一行後,我創建的下一行將編輯設置爲true。我不確定這是爲什麼,但是這意味着在刪除一行後,我創建的下一行是indented on the left side by about 40 pointsiOS Swift:UITableViewCell在刪除行後設置爲true

移除單元格之後,我需要將表格或單元格設置爲editing = false嗎?

func removeItems(items: [CKRecord], indexPath: NSIndexPath) { 
    for item in items { 
     db.deleteRecordWithID(item.recordID) { (record, error) -> Void in 
      if error != nil { 
       println(error.localizedDescription) 
      } 

      dispatch_async(dispatch_get_main_queue()) {() -> Void in 
       if let index = find(exercises, item) { 
        exercises.removeAtIndex(index) 
       } 
      } 
     } 
    } 

    days.removeAtIndex(indexPath.row) 
    tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic) 
} 
+0

將'cell.editing = false'添加到'cellForRowAtIndexPath'解決了這個問題,但它看起來很沉重。 – colindunn 2015-03-08 21:47:02

回答

0

顯然刪除一行並不禁用該行的編輯。我加deleteRowsAtIndexPaths之前這條線,這似乎這樣的伎倆:

tableView.cellForRowAtIndexPath(indexPath)?.setEditing(false, animated: false)

我的理解是,當我刷上一個細胞,我能夠編輯該小區。並且因爲我插入的下一個單元格處於相同的索引處,所以正在繪製並啓用編輯。