In my ViewController.m I have declared
@interface ViewController ()
{
//...
UIAlertView * alertView;
//...
}
The alertview is created here:
- (void)iCloudTeavitused {
//...
//If the alertview happens to be previously open, it will be dismissed (I use a corresponding flag to indicate this)
[alertView dismissWithClickedButtonIndex:alertView.cancelButtonIndex
animated:YES];
//...
alertView = [[UIAlertView alloc] initWithTitle:AMLocalizedString(@"iCloud is available", @"iCloud is available")
message:AMLocalizedString(@"This app stores", @"This app automatically stores your settings in the cloud to keep them up-to-date across all your devices")
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:AMLocalizedString(@"OK_iCloudYES", @"OK"), nil];
[alertView show];
//...
}
I localize words by calling
LocalizationSetLanguage(@"en");
The localization takes place in Localization.m where I it also does:
ViewController* viewController = [[ViewController alloc]init];
[viewController iCloudTeavitused];
Thus, on some occasions, iCloudTeavitused gets called from ViewController.m also. The problem is that when it needs to dismiss the alert view (if one happens to be open) by calling
[alertView dismissWithClickedButtonIndex:alertView.cancelButtonIndex
animated:YES];
in iCloudTeavitused, this method actually doesn't get called (while, for example, creating another alertView
DOES get called).
My guess is that dismissing the old alertView
isn't fired because I'm calling this through Localization.m.
Am I right and what am I doing wrong in my code?