Sumi-Interactive / SIAlertView

An UIAlertView replacement with block syntax and fancy transition styles.
MIT License
2.51k stars 424 forks source link

On dismiss frozen UI. #42

Open olivierto opened 11 years ago

olivierto commented 11 years ago

Hello ! SIAlertview works like charm but here is a tricky situation that always freezes my interface.

I got an alert showing (a SIAlertView latest release).

An async event (eg. push notif) comes out. This event is likely to show a modal view controller. Everythings works fine, the alert is still in foreground and the modal view controller is background.

BUT when i click to dismiss the alert, the interface of my view controller behind do not respond anymore.

I think this bug is generated by the window it creates... but not sure...

kyoji2 commented 11 years ago

iOS 5 or 6? Showing alert in main thread?

olivierto commented 11 years ago

it's on iOS6 the alert appears from main thread (do i need to try in a secondary thread?) the async action comes from a secondary thread

kyoji2 commented 11 years ago

It's fine. Set a break point after dismissal, use po [view recursiveDescription] to print out your view hierarchy. Try to find out if there is any view block the tap event.

olivierto commented 11 years ago

after dismissal ? you mean in the didDismiss handler ?

olivierto commented 11 years ago

I debugged the view hierarchy but it gives me nothing... (i placed a break point in the teardown method).

The alert view is showing in a custom vc. A push notification comes up. Here is my piece of code which is launched when it receives a push notification.

AlerteViewController *alVC=[[AlerteViewController alloc] init];
UINavigationController *navVC= [[UINavigationController alloc] initWithNavigationBarClass:[CustomNavigationBar class] toolbarClass:nil];
navVC.viewControllers  = @[alVC];
id rvc = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
[rvc presentViewController:navVC animated:YES completion:nil];

the view controller is appearing behind the alertview. And after, when i dismiss the alert the UI doesn't respond anymore :'(

I'm stucked ... thanks for your help

olivierto commented 11 years ago

ok here is a screen shot from spark inspector showing the view hierarchy after dismissal capture decran 2013-09-09 a 14 55 26 it looks like the window and background are still there after dismiss :octocat:

kyoji2 commented 11 years ago

Can you send your example code to me? I will take a look about that. kevincao[at]sumi-sumi.com

olivierto commented 11 years ago

sure i will make a dummy project with the same conditions to reproduce and i will send it to you as soon as possible.

realsnake commented 11 years ago

I meet the same issue on iOS7. After dismiss alert, my button on my view can't be touched, it seems tap is blocked by alert view, even it should be dismissed. The same code works fine in iOS6.

thomasthiriez commented 11 years ago

It was the UIWindow that caused the problem, indeed. I could fix it by adding a call to [window autorelease] just after it was created. I will submit a patch with the correction.

thomasthiriez commented 11 years ago

It seems the problem of the UIWindow not being correctly released was caused by me not compiling in ARC mode. Using ARC mode fixes this problem, and a few other crashes.

police02 commented 11 years ago

Me too ! same problem T T

mfkp commented 10 years ago

Has anybody been able to solve this? I've got the same problem as @realsnake, ios7 freezes up after dismiss (and I open up a new UIAlertView in the completion handler block). I've confirmed that it's being compiled with ARC.

mfkp commented 10 years ago

^ not sure of the scientific reasons why this works, but it fixed the problem for me.

ghost commented 10 years ago

I am having this issue as well in iOS 7. I see a fix was merged back in October, but still having problems with UI interactions failing after dismissal. Here is my usage, as you can see, very simple. UI is non-interactable after 'cancel' button is tapped and alert dismisses:

    SIAlertView *alertView = [[SIAlertView alloc] initWithTitle:@"Purchase Product" andMessage:@"You need to purchase this product.\n Would you like to visit the store now?"];
    [alertView addButtonWithTitle:@"View Store"
                             type:SIAlertViewButtonTypeDefault
                          handler:^(SIAlertView *alert) {
                              [self performSegueWithIdentifier:@"displayStore" sender:self];
                          }];
    [alertView addButtonWithTitle:@"Cancel"
                             type:SIAlertViewButtonTypeCancel
                          handler:^(SIAlertView *alert) {

                          }];
    alertView.transitionStyle = SIAlertViewTransitionStyleBounce;
    [alertView show];
ghost commented 10 years ago

I have the same problem on iOS 7 as @jhickman7. Although in my case the UI is blanked once a button is pressed. I messed around a bit as I was calling SIAlertView in the delete of an actionsheet. So I did this: [self performSelector:@selector(showSIAlertView) withObject:nil afterDelay:1.0f];

And it now works. Note that a delay of 0.2 did NOT work.

Cloudef commented 9 years ago

This is because of the oldKeyWindow (and similarly oldTintAdjustment). They will race when two alerts show up and other dismisses before other. (The other will have the other alerts keyWindow and tintAdjustment). So tint adjustments may appear wrong similarly as the UI may lock up. You should not rely on keeping the state yourself like this.

472574155 commented 8 years ago