Disable Live Text on UITextField

In iOS 15 you can double tap in a text field to reveal a "Scan Text" button which allows you to scan text from the camera. Is there a way to disable this ability on a specific UITextField programmatically?

Answered by Claude31 in 700772022

I would investigate in this direction:

  • subclass UITextField
  • disable double tap for liveText by overriding
    override func canPerformAction(action: Selector, withSender sender: AnyObject?) -> Bool { }
  • which assumes you can find the Selector associated to LiveText…

More details here for similar case:

https://stackoverflow.com/questions/42802276/how-to-disable-uitextfield-double-tap-or-long-press-in-swift-ios

Accepted Answer

I would investigate in this direction:

  • subclass UITextField
  • disable double tap for liveText by overriding
    override func canPerformAction(action: Selector, withSender sender: AnyObject?) -> Bool { }
  • which assumes you can find the Selector associated to LiveText…

More details here for similar case:

https://stackoverflow.com/questions/42802276/how-to-disable-uitextfield-double-tap-or-long-press-in-swift-ios

Disable all actions by UITextField subclass.

import UIKit

class CustomTextField: UITextField {
    override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
        return false
    }
}
Disable Live Text on UITextField
 
 
Q