Hossein Kiarsy
Hossein Kiarsy

Reputation: 13

Swift : present a ViewController while alert is shown

I have a problem with present UIViewController Modaly by above code

self.presentViewController(view, animated: true, completion: nil);

it doesn't work when another view present modaly such as UIAlert,its triggered by a socket packet in background and user may is performing another work and may another modal view already presented when the trigger happens.

Upvotes: 1

Views: 2385

Answers (1)

Denislava Shentova
Denislava Shentova

Reputation: 741

You can not present two view controllers at the same time from the same source controller. Instead, try presenting the second view controller from the first one that was presented.

       if let presented = self.presentedViewController {
            presented.present(vcToPresent, animated: true, completion: nil)
        }
        else {
            self.present(vcToPresent, animated: true, completion: nil)
        }

Upvotes: 8

Related Questions