Question

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.

Was it helpful?

Solution 3

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.

OTHER TIPS

I have some suggestions for you:

1) First check it out that your .xib file for iPhone5 is connected to the delegate of UISearchBar or not?

2) You can use one .xib file for both 3.5 inches and 4 inches and make this .xib for both iPhone 4 and 5 compatible by autoresizing.

Hopefully these point can resolve your problem.

Just like Irfan said, it will be because you haven't connected the delegates properly. check your xib file for the 4 inch screen. Also you could have done this in a single xib. just click off autolayout and adjust the resizing constraints for each element appropriately for better results.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top