UIAlertView warning when dismissing
Asked Answered
L

1

12

I'm creating an alert in the following manner:

let alert = UIAlertView(title: "Network Unavailable",
                      message: "Oh noes!",
                     delegate: nil,
            cancelButtonTitle: "OK")
alert.show()

Works fine. However when I click the 'OK' button to dismiss the alert, I get this:

Warning: Attempt to dismiss from view controller <_UIAlertShimPresentingViewController: 0x16ea2230> while a presentation or dismiss is in progress!

Some context:

  1. The alert is created in didMoveToView(view: SKView!) function of an SKScene.
  2. This is in Xcode 6 beta 3.
  3. my example is swift but this also happens from Objective-C

Any ideas why this warning might be occurring? I don't want to ignore it in case it turns into a fatal error in a future version of iOS.

UPDATE

I should also add that when the alert appears, when I select Debug -> View Debugging -> Capture View Hierarchy, the alert is not shown in the 3d view of the views. I'm wondering if this is symptomatic of something I'm doing wrong.

Leralerch answered 14/7, 2014 at 23:27 Comment(6)
Why obviously in Swift?! I personally think Swift is one of the most confusing, irritating and bad designed languages I've ever read... Nevertheless, I have the same issue and think this still might be a bug! Mind we're still in beta!Symer
@Julian - "obviously in swift" because the code example is swift not because the bug only manifests in Swift. OP is obviously concerned its a swift bug.Periodical
Have you tried these solutions: #14908018Periodical
I would have expected to be able to generate a UIAlertView from anywhere and would expect the default 'cancel' button to close that alert without me having to do anything for it to do so 'cleanly'. I have even tried creating the alert from within the main view controller but closing the alert gives the same warning in this case. I'm starting to suspect it is a bug.Leralerch
I'm having the same problem. Not using spritekit or Swift (100% objective-c). Tapping cancel causes the error, and makes the next actionsheet to load extremely slowly.Alongshore
Also, I've been trying to debug this and I noticed that didPresentActionSheet is NOT being called. This is consistent with it "not being displayed" technically.Alongshore
D
5

I was getting the same warning:

Warning: Attempt to dismiss from view controller <_UIAlertShimPresentingViewController:> while a presentation or dismiss is in progress!

In iOS8, UIAlertController replaces UIAlertView. This should resolve your warning (in Objc):

UIAlertController *alert =
  [UIAlertController alertControllerWithTitle:@"Network Unavailable"
                                      message:@"Oh noes!"
                               preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *cancelAction =
  [UIAlertAction actionWithTitle:@"Ok"   
                           style:UIAlertActionStyleCancel
                         handler:^(UIAlertAction *action) {
                                                        }];
[alert addAction:cancelAction];    
[self presentViewController:alert animated:YES completion:nil];

See the documentation for UIAlertController for more info.

Dost answered 31/7, 2014 at 0:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.