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

 

相关文章
相关标签/搜索