tags:

views:

96

answers:

3

I have tested my app on 3.1.3 and when the device language is set to German it displays the UISearchBar cancel button localized into German. On iOS4 it displays as "Cancel". Is there anything specific I need to do in iOS4 to trigger the cancel button to display as a localized string?

A: 

Same problem here!

I've tried to access the cancel button by iterating over the subviews of the search bar and set the title manually but the cancel button is always nil.

brutella
A: 

Change the Cancel button title:

for (UIView *subview in [searchBar subviews]) {
    if ([NSStringFromClass([subview class]) isEqualToString:@"UINavigationButton"]){
        // http://github.com/kennytm/iphone-private-frameworks/blob/master/UIKit/UINavigationButton.h
        [subview performSelector:@selector(setTitle:) withObject:@"newTitle"];
    }
}

You can also find the cancel button looking for an element with dimensions 48,30. Use CGRect bounds = [subview bounds]; CGSize size = bounds.size;

Jano