How to open the view with the keyboard appearing when the view is already loaded?

浪子不回头ぞ 提交于 2019-12-21 17:02:11

问题


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.


回答1:


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];
}


来源:https://stackoverflow.com/questions/2651136/how-to-open-the-view-with-the-keyboard-appearing-when-the-view-is-already-loaded

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!