I have an iOS application, built to support iOS5.1, and I was customizing the cancel button inside search bars.
The code I'm using and that works until iOS6.1 is the following:
id barButtonAppearanceInSearchBar =
[UIBarButtonItem appearanceWhenContainedIn: [UISearchBar class], nil];
[barButtonAppearanceInSearchBar setTitle:
[self localizedStringValueFor:@"Cancel"]];
Somehow the second line will cause a bad access exception, the barButtonAppearanceInSearchBar
seems to be deallocated when I try to set the value for the button's text.
localizedStringForValue
is a custom method that will return a String with the translation for the provided key or the key itself if not translation exists.
Now when I run the app on iOS7' simulator the app always crashes. Been trying to figure out what I'm doing wrong but no luck so far.