2016-05-12 21 views
0

Ich versuche, einen Übergang im Completion-Block einer Animation in Swift durchzuführen. Der Übergang dauert jedoch sehr lange (ca. 10 Sekunden) und ich bin mir nicht sicher warum. Hier ist der Code:Ich führe einen Übergang nach der Animation aus

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

     imageViewAnimated.startAnimating() 


     if label.center != CGPoint(x:50, y:10) { 

      UIView.animateWithDuration(2.0, delay: 0.0, usingSpringWithDamping: 0.0, initialSpringVelocity: 0.0, options: .CurveEaseOut, animations: {() -> Void in 
       self.label.center = self.view.center 

       }, completion: nil) 

      UIView.animateWithDuration(0.5, delay: 0.0, usingSpringWithDamping: 0.0, initialSpringVelocity: 0.0, options: .CurveEaseOut, animations: {() -> Void in 
       self.label.alpha = 0.0 

       }, completion: { finished in 

        self.poof.alpha = 1.0 
        self.performSegueWithIdentifier("backSegue", sender: nil) 
      }) 
     } 
    } 
+0

Ist die neue Ansicht eine Menge Daten geladen? – milesper

+0

Die neue Ansicht ist nichts anderes als ein Textfeld und eine Schaltfläche, aber in der alten Ansicht werden viele große Bilder geladen. – Bailey

+0

Warum wechseln Sie vom ViewController ab, sobald er angezeigt wird? – milesper

Antwort

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

      imageViewAnimated.startAnimating() 


      if label.center != CGPoint(x:50, y:10) { 

       UIView.animateWithDuration(2.0, delay: 0.0, usingSpringWithDamping: 0.0, initialSpringVelocity: 0.0, options: .CurveEaseOut, animations: {() -> Void in 
        self.label.center = self.view.center 

        }, completion: nil) 

       UIView.animateWithDuration(0.5, delay: 0.0, usingSpringWithDamping: 0.0, initialSpringVelocity: 0.0, options: .CurveEaseOut, animations: {() -> Void in 
        self.label.alpha = 0.0 

        }, completion: { finished in 

         self.poof.alpha = 1.0 
         dispatch_async(dispatch_get_main_queue(),{ 
          self.performSegueWithIdentifier("backSegue", sender: nil) 
         }) 
       }) 
      } 
     }