Wednesday, 8 April 2015

table cell swipe to delete and more actions.


1. Delete a line of data on uitableview:

Below code can help you to do this in your tablview controller:

    //MARK: Table edit : delete message from the list
    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 func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
        if editingStyle == .Delete {
            serverNotificationList?.removeAtIndex(indexPath.row)
            tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
        } else if editingStyle == .Insert {
            // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
        }

    }


2. more actions:

http://timbroder.com/2014/08/uitableviewcell-action-swiping-in-ios8-and-swift.html

http://www.appcoda.com/swipeable-uitableviewcell-tutorial/



No comments:

Post a comment