简体   繁体   中英

UIAlertView shows up several times after Home Button is pressed

Iam calling this Code in my ViewController if some Settings are not set or are (by the length) zero:

UIAlertView *infoView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Achtung", nil) message:NSLocalizedString(@"Wrong Settings",nil)delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [infoView show];
    [infoView release]; 

The Alertview shows up and if I press the Home Button and start the App again it shows the Alert zwice, after that if i press the Home Button again and start the App the Alert shows up 4 times.....

Why the hell is it like this?

I tried to define a new function for it and tried many other workarounds but nothing worked out for me.

Somebody any Suggestions?

Something like this

- (void)viewWillDisappear {
    [super viewWillDisappear];
    [myAlert dismissWithClickedButtonIndex:0 animated:NO];
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM