开发者

Set focus of UITextField of firstViewController on secondViewController

开发者 https://www.devze.com 2023-03-31 17:15 出处:网络
How do I set a particular UITextField on my firstViewController to focus when my sec开发者_StackOverflowondViewController pops from the navigationController?Write [TexfieldName becomeFirstResponder];i

How do I set a particular UITextField on my firstViewController to focus when my sec开发者_StackOverflowondViewController pops from the navigationController?


Write [TexfieldName becomeFirstResponder]; in ViewdidLoad in secondViewController.

This will focus to particular textField and show keyboard.


If you don't want to use viewWillAppear:, you could make use of the UINavigationControllerDelegate method – navigationController:willShowViewController:animated: and make invoke your method that way instead.

Just make sure some class is the delegate of you navigation controller, and get it to call a method in firstViewController invoking becomeFirstResponder.

EDIT: Link to the Apple documentation on UINavigationControllerDelegate.

0

精彩评论

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

关注公众号