1

From my initial View Controller, I want to be able to segue to another view controller. This second view controller, however, takes a few seconds to load, and I want to have my source view controller display an animation while it loads.

Performing the segue blocks the rest of the code from running, but I can't put it in a background thread because it technically updates the UI (Xcode gave me lots of warnings when I tried).

The animation also updates the UI, which means I can't put that in its own separate thread either.

Is there another method I could use to accomplish this?

class LaunchViewController: UIViewController {

    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)

        UIView.animateWithDuration(5, animations: {
               //Perform animation that updates the UI
        }, completion: nil)


        dispatch_async(dispatch_get_main_queue()) {
            self.performSegueWithIdentifier("seg", sender: self)
        }
}

P.S. When I put performSegueWithIdentifier in a background thread, it worked perfectly. But like I said, I get lots of errors (and Xcode will throw an exception in a coming release).

Lahav
  • 781
  • 10
  • 22

0 Answers0