Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why isn't UIAlertView Showing?

For some reason screen gets dark and freezes, alert is not shown... can someone please help?

Thanks in advance!

} else {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Hello!" 
                                                message:@"Hello!" delegate:self 
                                      cancelButtonTitle:@"Done" 
                                      otherButtonTitles:nil];
    [alert show];
    [alert release];
}
like image 952
Rui Avatar asked Dec 06 '22 22:12

Rui


1 Answers

You are probably calling show from a background thread, call it on the main thread like this:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Hello!" 
                                            message:@"Hello!" delegate:self 
                                            cancelButtonTitle:@"Done" 
                                            otherButtonTitles:nil];
[alert performSelectorOnMainThread:@selector(show)
                            withObject:nil
                            waitUntilDone:NO];
[alert release];
like image 195
Lachlan Roche Avatar answered Dec 23 '22 05:12

Lachlan Roche