ios8 新特性 UITableViewRowAction

// 原滑動刪除方法,需保留
    override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
        
    }
    
    // 滑動刪除與編輯
    override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject]? {
        
        var editAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "編輯") {
            (action: UITableViewRowAction!, indexPath:NSIndexPath!) -> Void in
            
           // 編輯的業務邏輯ide


        }
        
        var deleteAction = UITableViewRowAction(style: UITableViewRowActionStyle.Normal, title: "刪除") {
            (action: UITableViewRowAction!,indexPath: NSIndexPath!) -> Void in
            
           // 刪除的業務邏輯orm


        }
        
        // 設置背景顏色
        editAction.backgroundColor = UIColor.lightGrayColor()
        deleteAction.backgroundColor = UIColor.redColor()
        return [deleteAction, editAction]
    }it

 

相關文章
相關標籤/搜索