2016-05-12 1 views
0

J'essaie d'effectuer une séquence dans le bloc d'achèvement d'une animation dans Swift. Cependant, le segue prend beaucoup de temps (environ 10 secondes) à faire et je ne sais pas pourquoi. Voici le code:Exécution de segue après que l'animation prenne du temps

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

est la nouvelle vue du chargement d'un grand nombre de données? – milesper

+0

La nouvelle vue n'est rien d'autre qu'une zone de texte et un bouton, mais l'ancienne vue contient beaucoup de grandes images chargées. – Bailey

+0

Pourquoi êtes-vous en train de quitter le viewController dès qu'il apparaît? – milesper

Répondre

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) 
         }) 
       }) 
      } 
     }