我有一个简单的UIViewController和 a UISearchBar,当视图加载时,我想让搜索栏立即成为第一响应者,以便键盘显示并且他们可以立即开始输入查询。我尝试在viewWillAppear下面这样做,但没有任何运气:
- (void)viewWillAppear:(BOOL)animated
{
[productSearchBar becomeFirstResponder];
[super viewWillAppear:animated];
}
还有其他地方我应该打电话becomeFirstResponder还是UISearchBar应该完全打电话给其他地方?