here is my code:
UIAlertView *someError = [[UIAlertView alloc] initWithTitle:nil message:@"Server Error!" delegate:nil cancelButtonTitle: @"ok" otherButtonTitles: nil];
[someError show];
when I click the OK button, there is still a background indicator, and I press the screen, the status bar is flickering.
I found several answers, but they do not work, I changed my code to:
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertView *someError = [[UIAlertView alloc] initWithTitle:nil message:@"Server Error!" delegate:nil cancelButtonTitle: @"ok" otherButtonTitles: nil];
[someError show];
});
or set delegate:
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertView *someError = [[UIAlertView alloc] initWithTitle:nil message:@"Server Error!" delegate:self cancelButtonTitle: @"ok" otherButtonTitles: nil];
[someError show];
});
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
dispatch_async(dispatch_get_main_queue(), ^{
[alertView dismissWithClickedButtonIndex:buttonIndex animated:NO];
});
}
it still does not work, then I try:
UIAlertView *someError = [[UIAlertView alloc] initWithTitle:nil message:@"error" delegate:nil cancelButtonTitle: @"ok" otherButtonTitles: nil];
[someError performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:NO];
doesn't work, crazy, this doesn't work either:
[self performSelectorOnMainThread:@selector(showAlert:) withObject:@"error", nil) waitUntilDone:NO];
-(void)showAlert:(NSString*)str
{
UIAlertView *someError = [[UIAlertView alloc] initWithTitle:nil message: str delegate: nil cancelButtonTitle: @"ok" otherButtonTitles: nil];
[someError performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:NO];
}
still not working.
before and after warning:


source
share