搜索栏点击检测 [英] Search Bar click detect

查看:24
本文介绍了搜索栏点击检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个搜索栏,我想检测用户何时单击它,然后在用户在搜索栏中编辑时禁用按钮.我怎么能做到这一点,因为我试图做你会在上面看到的事情,但它从未被调用过.

I have a search bar and i want to detect when the user click it , and after to disable a button while the user is editing in search bar. How can i do this , because i was trying to do wha you will see above but it's never called.

-(void)searchBarSearchButtonClicked:(UISearchBar *)searchBar{
        NSLog(@"yes");
    }

其他方法如searchDisplayController被调用.我也设置了

Other methods like searchDisplayController are called.I set also

self.searchBar.delegate=self 

但没有结果.

推荐答案

可以直接使用UIsearchbar的delegate来获取点击事件.你可以使用这个委托来检查点击.以及结束编辑这第二个.

You can directly use the delegate of the UIsearchbar for getting the click event. you can use this delegate for it for checking the click. and for getting end editing this second one.

- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar
{
    NSLog(@"Yes");
    return YES;
}

结束编辑

- (BOOL)searchBarShouldEndEditing:(UISearchBar *)searchBar
{
    return YES;
}

这篇关于搜索栏点击检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆