79136687

Date: 2024-10-29 10:08:37
Score: 0.5
Natty:
Report link

A solution could be put a UIButton on top of UITextField to block interactions. So when user tap the button, all we have to do is make UITextField become first responder

enter image description here

class DisableTextField: UIViewController {

    @IBOutlet weak var textfield: UITextField!
    @IBOutlet weak var button: UIButton!
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }


    @IBAction func onTap(_ sender: Any) {
        textfield.becomeFirstResponder()
    }

}
Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: duckSern1108