Why isn't UIAlertView Showing?

前端 未结 4 1697
南笙
南笙 2021-01-06 11:12

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

Thanks in advance!

} else {
    UIAlertView *alert = [[U         


        
4条回答
  •  北荒
    北荒 (楼主)
    2021-01-06 11:49

    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];
    

提交回复
热议问题