技术文章分类(180)

技术随笔(11)

swift UITableView Delete Cell

UITableViewDataSource里的方法

注意要删除两个东西

1,数据要删除一行

2,然后删除teblviewcell

    // Override to support conditional editing of the table view.
    override func tableView(tableView: UITableView!, canEditRowAtIndexPath indexPath: NSIndexPath!) -> Bool {
        // Return NO if you do not want the specified item to be editable.
        return true
    }
    
    
    // Override to support editing the table view.
    override func tableView(tableView: UITableView!, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath!) {
        if editingStyle == .Delete {
            // Delete the row from the data source
            let row:Int = indexPath.row
            self.diaries.removeObjectAtIndex(row) 
            tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
        }
    }

 

posted @ 2014-07-07 18:26  坤哥MartinLi  阅读(495)  评论(0编辑  收藏  举报