Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIAlertView lags, leaves dim effect, then causes the screen to flicker on iOS 6.1

I haven't touched this code in a while so I'm wondering if there are any obvious things that would cause the problem I'm running into.

I'm displaying a UIAlertView to the user after they perform a search query. This worked fine until I started testing on iOS 6.1 (or this particular iPad 2 I'm using for that matter). Now it acts as normal until dismiss the UIAlertView and then the screen stays dimmed for a few seconds.

This didn't seem like a problem, other than a bit of lag, until I noticed that I could still touch a table view in my app which causes flickering of the screen to occur.

The code is on my github: ipwnstuff/shodan

like image 655
erran Avatar asked Feb 07 '13 05:02

erran


2 Answers

Make sure that you are displaying (and dismissing if doing so programmatically) the alert on the main thread, along with all other interactions with UIKit. The easiest way is to use a block:

dispatch_async(dispatch_get_main_queue(), ^{
    // Display/dismiss your alert
});
like image 153
lnafziger Avatar answered Sep 18 '22 07:09

lnafziger


Using lnafziger's answer I showed the alertView on the main thread rather than dismissing it. Which fixed the problem too.

[alert performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:YES];
like image 21
richy Avatar answered Sep 17 '22 07:09

richy