关闭UITableViewRowAction [英] Dismiss UITableViewRowAction
问题描述
我有一个自定义的UITableViewRowAction设置和工作。我唯一无法解决的是,一旦选择了一个动作,如何解除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];
}
感谢您的任何建议。
推荐答案
您解除了操作处理中的操作,该操作在点击操作时被调用。 文档描述了处理程序如下
You dismiss the action in the handler which gets called when the action is tapped. The documentation describes the handler as follows
当用户点击与此操作相关联的按钮时要执行的块。 UIKit会复制您提供的块。当用户选择此对象表示的操作时,UIKit会在应用程序的主线程上执行处理程序块。
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.
我想你是独立的可以只将表格视图编辑
属性设置为false。
Independently, I suppose you could just set the table views editing
property to false.
tableView.setEditing(false, animated: true)
这篇关于关闭UITableViewRowAction的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!