Reputation: 782
I have textfield that textfield.isUserInteractionEnabled = false
but I would to have the copy and paste enable in textfield in order when user select on it, it can open the menu to make copy, is there a way to make it?
Thanks
Upvotes: 0
Views: 235
Reputation: 782
I found the solution with tableView:
func tableView(_ tableView: UITableView, shouldShowMenuForRowAt indexPath: IndexPath) -> Bool {
return true
}
func tableView(_ tableView: UITableView, canPerformAction action: Selector, forRowAt indexPath: IndexPath, withSender sender: Any?) -> Bool {
if (action == #selector(UIResponderStandardEditActions.copy(_:))) {
return true
}
return false
}
func tableView(_ tableView: UITableView, performAction action: Selector, forRowAt indexPath: IndexPath, withSender sender: Any?) {
if let cell = tableView.cellForRow(at: indexPath) {
UIPasteboard.general.string = cell.textLabel?.text
}
}
Upvotes: 0