如何禁用"替换"长按UITextField的选项

时间:2017-03-09 05:30:00

标签: swift 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)
    }

}

我已经完成了禁用"粘贴"选项但无法禁用"替换"选项

1 个答案:

答案 0 :(得分:0)

这可能不是正确的解决方案,但可能有用:

$(window).load(fumction() {
     $("#collapse1").removeClass("collapse");
});

其中textField.autocorrectionType = .no 是您所需的textField