Reputation: 9990
I've noted that in the Facebook Messenger they display the UIMenu
when someone presses the UIContextualAction
.
I might be missing something, but I don't see how to do it. If someone knows the code to do this, I would highly appreciate it.
Upvotes: 3
Views: 759
Reputation: 196
Okay so I don't love this method, but so far this has worked for me. I found this solution to access the UIButton, which you can then set a menu for.
func tableView(_ tableView: UITableView, willBeginEditingRowAt indexPath: IndexPath) {
for subview in tableView.subviews {
if NSStringFromClass(type(of: subview)) == "_UITableViewCellSwipeContainerView" {
for swipeContainerSubview in subview.subviews {
if NSStringFromClass(type(of: swipeContainerSubview)) == "UISwipeActionPullView" {
for case let button as UIButton in swipeContainerSubview.subviews {
var menuItems = [UIAction]()
menuItems.append(UIAction(title: "Test") { action in
print("Test")
})
button.showsMenuAsPrimaryAction = true
button.menu = UIMenu(title: "", children: menuItems)
}
}
}
}
}
}
Upvotes: 2