Swift UITextfield add click method – simple implementation

1. Truly effective in any system.

   1./// City choicePrivate lazy var cityTextfield:UITextField = {Let TF = UITextField ()Tf.deLegate = selfReturn TF} ()Two/ / / click the city@objc func clickCityTextfield () {Self.view.endEditing (true)View.showHud ()Self.requestForCity (ProtocolFollower: s)ELF)}3. extension JYShopAreaVc: UITextFieldDelegate{Func textFieldShouldBeginEditingTextField: UITextField) -> Bool {Self.clickCityTextfield ()Return false}}

The following is the wrong way.
1. No problem on iOS 11. It can be edited directly on iOS10 and iOS9.

    /// City choicePrivate lazy var cityTextfield:UITextField = {Let TF = UITextField ()/ / addThe gesture triggers the click effect directly and adds no response to the editing effect. Tf.addTarget can not.Tf.addGestureRecognizer (UITapGestureRecognizer (target:)Self, action: #selector (clickCityTextfield))Return TF} ()

  

  

Leave a Reply

Your email address will not be published. Required fields are marked *