I am trying to change MFmailComposer Language programmatically. Initially if I select the "English mail" button first MFMailComposer is opening in English language. now if I select "Arabic Mail" button then MFMailComposer will open in English Language, not in Arabic Language.
Here is the screenshot of my ViewController
So, how to change MFMailComposer Language Programmatically without restarting the application?
Here is code
- (IBAction)showInArabic:(id)sender
{
[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"ar", nil] forKey:@"AppleLanguages"];
[[NSUserDefaults standardUserDefaults] synchronize];
[self viewDidUnload];
[self viewDidLoad];
Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
if (mailClass != nil)
{
if ([mailClass canSendMail])
{
[self displayComposerSheet];
} else {
[self launchMailAppOnDevice];
}
} else {
[self launchMailAppOnDevice];
}
}
- (IBAction)showInEnglish:(id)sender
{
[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"en", nil] forKey:@"AppleLanguages"];
[[NSUserDefaults standardUserDefaults] synchronize];
NSArray *languages = [NSArray arrayWithObject:@"en"];
[[NSUserDefaults standardUserDefaults] setObject:languages forKey:@"AppleLanguages"];
[self viewDidUnload];
[self viewDidLoad];
Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
if (mailClass != nil) {
if ([mailClass canSendMail]) {
[self displayComposerSheet];
} else {
[self launchMailAppOnDevice];
}
} else {
[self launchMailAppOnDevice];
}
}