I am writing an iOS app, which operates in a multi-language environment. As a consequence the program can operate in a language different than the system language. Example: my phone is running in English and the program runs in German or French. All texts are displayed in the correct language.
Now I want, that VoiceOver speaks the texts in the correct language, which works most times fine by using the following method:
- (void)setVoLanguage:(NSObject*)object
{
if (prefLanguage == 0){
[object setAccessibilityLanguage:@"de-DE"];
} else {
[object setAccessibilityLanguage:@"fr-FR"];
}
}
I am trying to let VoiceOver speak the texts in the navigation controller in the correct language using one of the following approaches:
[self setVoLanguage:navController];
[self setVoLanguage:navController.title];
[self setVoLanguage:navController.navigationBar.topItem];
[self setVoLanguage:navController.navigationBar.backItem];
[self setVoLanguage:navController.navigationBar.topItem.title];
[self setVoLanguage:navController.navigationBar.backItem.title];
[self setVoLanguage:navController.navigationBar.topItem.titleView];
[self setVoLanguage:navController.navigationBar.backItem.titleView];
But the result is, that the german or french texts in the navigation bar are always spoken using the English voice.
Does anybody know how to switch the VoiceOver language in the navigation bar?
Thank you.
Update: here is a work around, which works for me using iOS 5.1.1:
- (NSString *)accessibilityLanguage {
cnlAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
if (appDelegate != nil) {
if ([appDelegate prefLanguage] == 0) {
return @"de-DE";
} else {
return @"fr-FR";
}
}
return @""; // this line should never be reached
}
My appDelegate object is the object, which stores the current language. Overwriting accessibilityLanguage for all objects seems to resolve the problem.
I hope this might be of use for someone out there.