2016-05-12 37 views
0

我试图在Swift中的动画完成块中执行一个segue。然而,赛格需要很长时间(大约10秒)才能完成,我不知道为什么。下面的代码:在动画需要很长时间之后执行segue

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

是加载大量数据的新的看法? – milesper

+0

新的视图不过是一个文本框和按钮,但旧视图中有很多大图像被加载到它中。 – Bailey

+0

为什么一出现viewservler就离开它? – milesper

回答

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) 
         }) 
       }) 
      } 
     } 
相关问题