在动画需要很长时间之后执行segue
问题描述:
我试图在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)
})
}
}
答
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)
})
})
}
}
是加载大量数据的新的看法? – milesper
新的视图不过是一个文本框和按钮,但旧视图中有很多大图像被加载到它中。 – Bailey
为什么一出现viewservler就离开它? – milesper