Reputation: 3249
in iOS5.0 using arc I need to change the word 'cancel' in the cancel button of the UISearchDisplayController to a word derived from the language selected by the user. Since the language is not selected based on localisation, so I cannot just use that. The word comes from a web service. I found a way to do it by walking the subviews in the post below, but is there any other way to do it without assuming apple's view hierarchy?
Upvotes: 2
Views: 3197
Reputation: 14857
If you want to localize 'cancel' button's title based on different language in iOS System.You can change the CFBundleDevelopmentRegion
key in Info.plist
.
<key>CFBundleDevelopmentRegion</key>
<string>en,ru,zh_CN</string>
Or you can select them in Info.plist
file with Xcode Editor.
Here is the Language ID from Apple Doc.
Upvotes: 6
Reputation: 2519
try this
[[UIButton appearanceWhenContainedIn:[UISearchBar class], nil]
setTitle:@"button title"
forState:UIControlStateNormal];
if you want to change hint text
[[UITextField appearanceWhenContainedIn:[UISearchBar class], nil]
setPlaceholder:@"text hint"];
Upvotes: 0
Reputation: 539815
It seems that you can use the UIAppearance
protocol to achieve this:
[[UIButton appearanceWhenContainedIn:[UISearchBar class], nil]
setTitle:@"Hello world" forState:UIControlStateNormal];
I did only a quick check with the "TableSearch" sample project from Apple, where it worked.
Upvotes: 1