Swift UITextFieldShouldReturn Return Key Tap

后端 未结 4 1897
旧时难觅i
旧时难觅i 2021-02-01 01:26

(iOS8, Xcode6, Swift) Using Swift, how do I capture a tap on the \"Return\" button?

The doc at the following link specifies using the textFieldShouldReturn

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-01 01:53

    You need to set an object as the text field's delegate. Usually that would be the view controller that the text field exists in. You don't need to inherit from any other class, or, strictly speaking, implement a delegate (but you could implement UITextFieldDelegate to make things a little clearer.)

提交回复
热议问题