[英]How to open the view with the keyboard appearing when the view is already loaded?
I have a requirement where I have a textfield in a view. 我有一个要求,我在视图中有一个文本字段。 When I want to open the view by switching the tab (TabBased Application), first time when the view is loaded the keyboard appears because i loadview method is called. 当我想通过切换选项卡(TabBased Application)打开视图时,第一次加载视图时键盘出现,因为我调用了loadview方法。 But when I switch to tab2 and again switch to tab1 again, load view is not called. 但是当我切换到tab2并再次切换到tab1时,不会调用加载视图。 I want the keyboard to appear every time I open the tab1 page. 我希望每次打开tab1页面时都会出现键盘。
Use -viewWillAppear:
in your view controller to send your text field a -becomeFirstResponder
message, eg: 使用-viewWillAppear:
在视图控制器中发送文本字段-becomeFirstResponder
消息,例如:
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[myTextField becomeFirstResponder];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.