Why is UIAlertView not displayed?

For some reason, the screen goes dark and freezes, a warning is not displayed ... can someone help?

Thanks in advance!

} else { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Hello!" message:@"Hello!" delegate:self cancelButtonTitle:@"Done" otherButtonTitles:nil]; [alert show]; [alert release]; } 
+4
source share
4 answers

You are probably calling show from a background thread, calling it in the main thread as follows:

 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Hello!" message:@"Hello!" delegate:self cancelButtonTitle:@"Done" otherButtonTitles:nil]; [alert performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:NO]; [alert release]; 
+15
source

The delegate is true, but perhaps because you are doing the release at the end, this can cause problems.

Try with delegate nil :-)

For instance:

 UIAlertView *alertView; alertView = [ [ UIAlertView alloc ] init ]; [ alertView setMessage:@"Hello World" ]; [ alertView show ]; [ alertView release ]; 

If this works, then that was the delegate, and you need to declare the variable as a class var. Or it could be somewhere else.

0
source

Perhaps this warning sits in a large loop and you are not running on multiple threads? The screen is darkened and nothing happens - this is what I equate to a lengthy process in the main thread (therefore, the user interface does not update and does not show a warning).

0
source

You get a dark screen without a popup or a slower popup if you show a UIAlertView from a background thread. Just put it back in the main thread and everything will be fine. I had this problem last week.

0
source

Source: https://habr.com/ru/post/1344006/


All Articles