我已经使用了对表视图的行实现了一些编辑操作UITableViewRowAction.其中一个是删除操作,我想提供一个包含操作表的popover来确认删除操作.因此,我需要一个删除按钮视图的引用,以将其传递给UIPopoverPresentationController.
有什么办法可以访问UITableViewRowAction对象的视图吗?
为了澄清一点,我尝试访问的视图是红色删除按钮,标记为绿色:

抱歉,我不知道它的 Objective-C 版本,但我现在正在 Swift 的一个项目中使用它,它应该可以工作。不过这只是 iOS 8,我不确定在此之前是否有办法做到这一点。
func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject]? {
var deleteButton: UITableViewRowAction = UITableViewRowAction(style: .Default, title: " ", handler: { (action, indexPath) in
// put whatever you need to call here. below is the default code, which will delete the cell as usual.
self.tableView.dataSource?.tableView?(
self.tableView,
commitEditingStyle: .Delete,
forRowAtIndexPath: indexPath
)
return
})
}
return [deleteButton]
}
Run Code Online (Sandbox Code Playgroud)
您的另一个选择是使用 tableview 函数:
func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath)
Run Code Online (Sandbox Code Playgroud)
您可以在其中创建弹出窗口并让他们确认。实际上,这可能会更好,我相信这正是函数的用途。
编辑:忘记了第一段代码中的 return [deleteButton] 。
| 归档时间: |
|
| 查看次数: |
864 次 |
| 最近记录: |