Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
105 views
in Technique[技术] by (71.8m points)

ios - Dismiss UITableViewRowAction

I have a custom UITableViewRowAction set up and working. The only thing I can't work out is how to dismiss the UITableViewRowAction once an action has been selected. I'm sure I'm missing something really obvious. Here is my current setup:

func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject]? {

    var moreRowAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "In", handler:{action, indexpath in
        //Some code to execute here
    });
    moreRowAction.backgroundColor = UIColor(red: 0.298, green: 0.851, blue: 0.3922, alpha: 1.0)

    return [moreRowAction];
}

Thanks for any advice.

question from:https://stackoverflow.com/questions/26197826/dismiss-uitableviewrowaction

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You dismiss the action in the handler which gets called when the action is tapped. The documentation describes the handler as follows

The block to execute when the user taps the button associated with this action. UIKit makes a copy of the block you provide. When the user selects the action represented by this object, UIKit executes your handler block on the app’s main thread.

Independently, I suppose you could just set the table views editing property to false.

tableView.setEditing(false, animated: true)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...