I wish to change the title of the cancel button in iOS. I have been using this previously:
- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayCon
here is my solution for both ios6 & ios7
#define IS_IOS7 (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1)
- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller
{
self.searchDisplayController.searchBar.showsCancelButton = YES;
UISearchBar *searchBar = self.searchDisplayController.searchBar;
UIView *viewTop = IS_IOS7 ? searchBar.subviews[0] : searchBar;
NSString *classString = IS_IOS7 ? @"UINavigationButton" : @"UIButton";
for (UIView *subView in viewTop.subviews) {
if ([subView isKindOfClass:NSClassFromString(classString)]) {
UIButton *cancelButton = (UIButton*)subView;
[cancelButton setTitle:@"your title" forState:UIControlStateNormal];
}
}
}