美文网首页
swift tableview 使用

swift tableview 使用

作者: 剌小胥 | 来源:发表于2016-05-16 17:05 被阅读111次
    // 删除单元格

    func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
        if editingStyle == .Delete {
            self.deleteMedia(indexPath.row)
            tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Fade)
        }
    }

    // 左滑动单元格 添加更多方法

    func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {
        let replaceAction = UITableViewRowAction(style: .Default, title: "更换") { (action:UITableViewRowAction, indexPath:NSIndexPath) in

        }

        replaceAction.backgroundColor = NAVBARCOLOR

        let deleteAction = UITableViewRowAction(style: .Default, title: "删除") { (action:UITableViewRowAction, indexPath:NSIndexPath) in
            self.deleteMedia(indexPath.row)
            tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Fade)
        }
        
        return [deleteAction, replaceAction]
    }

相关文章

网友评论

      本文标题:swift tableview 使用

      本文链接:https://www.haomeiwen.com/subject/nsvbrttx.html