iphone - 如何删除 UISearchBar 中的工具提示

标签 iphone objective-c xcode uisearchbar

我仍在开发我的应用程序,并且对 UISearchBar 有疑问。 enter image description here 这是我的问题:如何摆脱 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/

相关文章:

iphone - 调试-[NSCFDictionary setObject :forKey:]: attempt to insert nil value

iphone - 如何将我的 iphone 应用程序与 twitter api 集成?

Xcode 测试失败不会失败 Github 操作管道

iPhone 个人开发者责任

ios - 当 view1 帧触摸 view2 帧时停止动画

ios - 在库中子类化私有(private)类

iphone - 更改导航栏的字体

swift - Swift 中的 NSData 到 String

ios - 如何在不使用按钮的情况下直接点击将显示地址的单元格?

iphone - 核心数据 - "NSObjectInaccessibleException - CoreData could not fulfill a fault"