Custom UITextField to Disallow All Actions like Copy Paste etc
suggest changeIf we want to disable all the actions like Copy, Paste, Replace, Select, etc from UITextField
then we can use following custom text field:
class CustomTextField: UITextField {
var enableLongPressActions = false
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)!
}
override init(frame: CGRect) {
super.init(frame: frame)
}
override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
return enableLongPressActions
}
}
Using enableLongPressActions
property, we can enable all actions any time later, if needed.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents