Search code examples
iosios7xcode5uisearchbariphone-5

UISearchBar delegate functions are not responsing


UISearchBar delegate functions are not responding for iOS7 iPhone5 only. I have two .xib files in my code one for 3.5 inch screen and one for 4 inch screen. For 3.5 inch screen, it's working fine but for 4 inch screen the delegate functions are not being called. Can you please guide me?

- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar {
    [searchBar setShowsCancelButton:YES animated:YES];
    [self keyboardWillShow];
}

- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar {
    [self keyboardWillHide];
    searchBar.text=@"";

    [searchBar setShowsCancelButton:NO animated:YES];
    [searchBar resignFirstResponder];
}

- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar 

this function is called but searchBarCancelButtonClicked doesn't work.


Solution

  • All was good. It was my mistake. I was applying an overlay view wich was covering the cancel button. I removed that overlay and it worked fine.