我仍在开发我的应用程序,并且对 UISearchBar 有疑问。 这是我的问题:如何摆脱 UISearchBar 中出现的“选择|全选|粘贴”工具提示? 谁能帮我这个?预先感谢您。
最佳答案
如果您只想为 UISeacrhBar
隐藏它,则:
-(void)setGestures
{
for (id obj in searchBar.subviews)
{
if ([obj isKindOfClass:[UITextField class]])
{
UITextField *textF = (UITextField *)obj;
textF.gestureRecognizers = nil;
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(makeSearchBarFirstResponder:)];
textF.gestureRecognizers = @[tapGesture];
}
}
}
-(void)makeSearchBarFirstResponder:(UIGestureRecognizer *)sender
{
[sender.view becomeFirstResponder];
}
并在
中调用[self setGestures]
方法
-(void)viewDidLoad
{
[self setGestures];
}
-(BOOL)searchBar:(UISearchBar *)searchBar shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
[self setGestures];
return YES;
}
关于iphone - 如何删除 UISearchBar 中的工具提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18122003/