From cff334ef0eba6e629517dc36d0d00c49a3190b21 Mon Sep 17 00:00:00 2001 From: Bob Sun Date: Fri, 3 Feb 2017 18:02:40 +0800 Subject: [PATCH] long press password to copy --- pass/PasswordDetailTableViewController.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pass/PasswordDetailTableViewController.swift b/pass/PasswordDetailTableViewController.swift index 94194fe..b2b4763 100644 --- a/pass/PasswordDetailTableViewController.swift +++ b/pass/PasswordDetailTableViewController.swift @@ -45,6 +45,20 @@ class PasswordDetailTableViewController: UITableViewController { return cell } + override func tableView(_ tableView: UITableView, performAction action: Selector, forRowAt indexPath: IndexPath, withSender sender: Any?) { + if action == #selector(copy(_:)) { + UIPasteboard.general.string = formData[indexPath.section][indexPath.row].content + } + } + + override func tableView(_ tableView: UITableView, canPerformAction action: Selector, forRowAt indexPath: IndexPath, withSender sender: Any?) -> Bool { + return action == #selector(UIResponderStandardEditActions.copy(_:)) + } + + override func tableView(_ tableView: UITableView, shouldShowMenuForRowAt indexPath: IndexPath) -> Bool { + return true + } + override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return 52 }