开发者

SearchBar not working when search button is clicked

Can anyone help me out, i am working with开发者_JAVA百科 UISearchBar and want that when i write anything in SearchBar and press enter key, it will start desired operation...

I have read searchBarSearchButtonClicked function will get called once the “Search” button will be clicked on the pop-up keyboard window. But it is not called:( I have implemented as:

  • (void) searchBarSearchButtonClicked:(UISearchBar*) searchContact { //do some thing }

i have checked by placing breakpoints infact this function is not being called....

any idea??

Thanks!!


Did you assign delegate to that viewcontroller which implemented "searchBarSearchButtonClicked" ?

You need to assign delegate like this.

searchBar.delegate =self;


You need to implement the UISearchBarDelegate protocol and set the delegate of the textfield to the class which implements this protocol.

This is the reason why the delegate is not getting called.

You can try this,

In IB set the delegate to file's owner and implement the delegate.

In Code, if you hold reference to the search bar, then on viewDidLoad

searchBar.delegate = self;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜