我希望在客户选择标签栏上的搜索菜单时激活搜索栏并显示键盘。但是resignfirstresponder不起作用。你有其他建议吗?谢谢你的批准。 这是我的viewdidload方法
[[UITextField appearanceWhenContainedInInstancesOfClasses:@[[UISearchBar class]]] setTextColor:[UIColor grayColor]];
[[UITextField appearanceWhenContainedInInstancesOfClasses:@[[UISearchBar class]]] setBackgroundColor:[UIColor whiteColor]];
_searchBarNew.placeholder = [MCLocalization stringForKey:@"courses"];
_searchBarNew.backgroundImage = [UIImage imageNamed:@"grey_background"];
_searchBarNew.delegate = self;
答案 0 :(得分:0)
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]
initWithTarget:self
action:@selector(dismissKeyboard)];
[self.view addGestureRecognizer:tap];
Once your requirement is done , tap anywhere in the screen to resign the keyboard
-(void)dismissKeyboard {
[TxtFieldObj resignFirstResponder];
}