devang bhatt
devang bhatt

Reputation: 470

How to disable "Replace" option on long pressed of UITextField

extension UITextField {
    override func target(forAction action: Selector, withSender sender: Any?) -> Any? {

        if #available(iOS 10, *) {
            if action == #selector(UIResponderStandardEditActions.paste(_:)) {
                return nil
            }
        } else {
            if action == #selector(paste(_:)) {
                return nil
            }
        }
        return super.target(forAction: action, withSender: sender)
    }

}

I have done with disabling "Paste" option but not able to disable "Replace" option

Upvotes: 1

Views: 648

Answers (1)

chengsam
chengsam

Reputation: 7405

It may not be the correct solution but may be useful:

textField.autocorrectionType = .no

where textField is your desired UITextField.

Upvotes: 1

Related Questions