I'm having a problem where all the UIAlertView
s in my app take quite some time to show up. The display dims instantly but the actual alert needs like 5 seconds to be displayed.
I'm creating them like this:
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Title"
message:@"Message"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
[alertView release];
Anyone ever had this?
Thanks
–f
If you try to show UIAlertView NOT from main thread, you can see this type of delay (and, sometimes, more serious bugs and crashes).
Extract code as a separate method and call it using "performSelectorOnMainThread", or use GCD and dispatch it there.
What are you doing after that code? If you do some computations and go on to work on things, the alert would not display. It is only displayed at the end of the runloop. The best way to handle this is to split up the work into smaller chunks, doing one after the other, while letting the runloop process events in between. Or offloading the heavy lifting to a background thread.
If you just what to try, if this is indeed the problem you are experiencing, try to add
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.01]];
just below your code above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With