本文介绍了当视图已经加载时,如何在出现键盘的情况下打开视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在视图中有文本框的地方.当我想通过切换选项卡(基于Tab的应用程序)打开视图时,第一次加载视图时会出现键盘,因为调用了loadview方法.但是,当我切换到tab2并再次切换到tab1时,不会调用加载视图.我希望每次打开tab1页面时都出现键盘.
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. But when I switch to tab2 and again switch to tab1 again, load view is not called. I want the keyboard to appear every time I open the tab1 page.
推荐答案
在视图控制器中使用 -viewWillAppear:
向您的文本字段发送 -becomeFirstResponder
消息,例如:
Use -viewWillAppear:
in your view controller to send your text field a -becomeFirstResponder
message, e.g.:
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[myTextField becomeFirstResponder];
}
这篇关于当视图已经加载时,如何在出现键盘的情况下打开视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!