开发者

iPhone: how can I activate a text field programmatically (and not wait for the user to touch it)

开发者 https://www.devze.com 2023-01-03 19:46 出处:网络
I have a UIViewController that is a UITextFieldDelegate, and I would like the keyboard for its text field to appear as soon as the user navigates to this view, without having to actually touch the tex

I have a UIViewController that is a UITextFieldDelegate, and I would like the keyboard for its text field to appear as soon as the user navigates to this view, without having to actually touch the text field. It would also be nice to be able to "dismiss" the entire view when the keyboard is dismissed. I am loading the view from a xib file.

I don't have an ivar in the code for the UITextField as yet. I would guess I need one. At this point I am just relying on the delegat开发者_JS百科e to pop up the keyboard.

(I know its not a UITextViewDelegate, like the tag says, but I am new to stackoverflow and can't create the correct UITextFieldDelegate tag.)


Sounds like you want to use [textField becomeFirstResponder] in viewDidAppear.

0

精彩评论

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

关注公众号