tap to show copy menu

This commit is contained in:
Bob Sun 2017-02-05 00:35:23 +08:00
parent 5a0b97b22f
commit 67570256d0
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
3 changed files with 38 additions and 5 deletions

View file

@ -13,6 +13,12 @@ class LabelTableViewCell: UITableViewCell {
@IBOutlet weak var contentLabel: UILabel!
@IBOutlet weak var titleLabel: UILabel!
override var canBecomeFirstResponder: Bool {
get {
return true
}
}
override func awakeFromNib() {
super.awakeFromNib()
}
@ -20,5 +26,12 @@ class LabelTableViewCell: UITableViewCell {
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
return action == #selector(copy(_:))
}
override func copy(_ sender: Any?) {
UIPasteboard.general.string = contentLabel.text
}
}