开发者

UITextField not updating

开发者 https://www.devze.com 2023-04-09 15:58 出处:网络
I\'m having trouble updating the UITextField for an iPhone app. I\'ve set the layout with the Interface Builder, created an instance of the text field in the ViewController, and set the ViewController

I'm having trouble updating the UITextField for an iPhone app. I've set the layout with the Interface Builder, created an instance of the text field in the ViewController, and set the ViewController as the delegate for the text field.

The text field obje开发者_如何学编程ct in code doesn't seem to be responding when I enter in information and press Done.

Does anyone have any ideas why its not working?


If you are creating the text field in interface builder, you don't need to also alloc and init it in code. Link the text field to files owner in IB (I'm assuming files owner is your view controller) as the delegate. If you need to refer to it specifically, also create and outlet in your view controller and link that to your text field. This is covered in the most basic tutorial apps in the docs.

To respond when the done button is pressed, implement the textFieldShouldReturn method from the UITextFieldDelegate protocol. Resign first responder in that method and return YES.


Is your text field connected to the IBOutlet in your code? Maybe if you post some related code it would be helpful.

0

精彩评论

暂无评论...
验证码 换一张
取 消