Segue 动画出现黑屏/出现故障并延长滑动手势长度
Black Screen on Segue Animation / Glitchy & Extend swipe gesture length
我一直在学习如何实现自定义转场的教程。使用滑动手势 - 我滑动我的手指,segue 工作但不是平滑过渡,第二个 ViewController 滑动 upwards/downwards 来替换当前的,我得到一个黑屏然后目的地 ViewController 加载..
这发生在前进和后退转场上。
我已经附上了正常转场(不是倒带)的动画代码。
此外,当我轻轻滑动屏幕时,segue 会立即发生。我将如何做到这一点,以便在我的手指松开(或者在模拟器的情况下,单击鼠标)之前不会发生 segue。我必须使用 scrollViews 吗?或者仅使用 swipeGestureRecognizers 和自定义 segues 就可以实现这种效果。
谢谢!
class FirstCustomSegue: UIStoryboardSegue {
override func perform() {
// Animate the transition.
UIView.animateWithDuration(0.4, animations: { () -> Void in
firstVCView.frame = CGRectOffset(firstVCView.frame, 0.0, -screenHeight)
secondVCView.frame = CGRectOffset(secondVCView.frame, 0.0, -screenHeight)
}) { (Finished) -> Void in
// Animate the transition.
UIView.animateWithDuration(0.4, animations: { () -> Void in
firstVCView.frame = CGRectOffset(firstVCView.frame, 0.0, -screenHeight)
secondVCView.frame = CGRectOffset(secondVCView.frame, 0.0, -screenHeight)
}) { (Finished) -> Void in
self.sourceViewController.presentViewController(self.destinationViewController as! UIViewController,
animated: false,
completion: nil)
}
}
}
}
试试这个代码,我更改了 self.destinationViewController...
上的最后一行
class FirstCustomSegue: UIStoryboardSegue {
override func perform() {
// Animate the transition.
UIView.animateWithDuration(0.4, animations: { () -> Void in
firstVCView.frame = CGRectOffset(firstVCView.frame, 0.0, -screenHeight)
secondVCView.frame = CGRectOffset(secondVCView.frame, 0.0, -screenHeight)
}) { (Finished) -> Void in
// Animate the transition.
UIView.animateWithDuration(0.4, animations: { () -> Void in
firstVCView.frame = CGRectOffset(firstVCView.frame, 0.0, -screenHeight)
secondVCView.frame = CGRectOffset(secondVCView.frame, 0.0, -screenHeight)
}) { (Finished) -> Void in
self.sourceViewController.presentViewController(self.storyboard.instantiateViewControllerWithIdentifier("YOUR_IDENTIFIER"),
animated: false,
completion: nil)
}
}
}
}
将 YOUR_IDENTIFIER
替换为与您的视图控制器匹配的故事板 ID。
我一直在学习如何实现自定义转场的教程。使用滑动手势 - 我滑动我的手指,segue 工作但不是平滑过渡,第二个 ViewController 滑动 upwards/downwards 来替换当前的,我得到一个黑屏然后目的地 ViewController 加载..
这发生在前进和后退转场上。
我已经附上了正常转场(不是倒带)的动画代码。
此外,当我轻轻滑动屏幕时,segue 会立即发生。我将如何做到这一点,以便在我的手指松开(或者在模拟器的情况下,单击鼠标)之前不会发生 segue。我必须使用 scrollViews 吗?或者仅使用 swipeGestureRecognizers 和自定义 segues 就可以实现这种效果。
谢谢!
class FirstCustomSegue: UIStoryboardSegue {
override func perform() {
// Animate the transition.
UIView.animateWithDuration(0.4, animations: { () -> Void in
firstVCView.frame = CGRectOffset(firstVCView.frame, 0.0, -screenHeight)
secondVCView.frame = CGRectOffset(secondVCView.frame, 0.0, -screenHeight)
}) { (Finished) -> Void in
// Animate the transition.
UIView.animateWithDuration(0.4, animations: { () -> Void in
firstVCView.frame = CGRectOffset(firstVCView.frame, 0.0, -screenHeight)
secondVCView.frame = CGRectOffset(secondVCView.frame, 0.0, -screenHeight)
}) { (Finished) -> Void in
self.sourceViewController.presentViewController(self.destinationViewController as! UIViewController,
animated: false,
completion: nil)
}
}
}
}
试试这个代码,我更改了 self.destinationViewController...
class FirstCustomSegue: UIStoryboardSegue {
override func perform() {
// Animate the transition.
UIView.animateWithDuration(0.4, animations: { () -> Void in
firstVCView.frame = CGRectOffset(firstVCView.frame, 0.0, -screenHeight)
secondVCView.frame = CGRectOffset(secondVCView.frame, 0.0, -screenHeight)
}) { (Finished) -> Void in
// Animate the transition.
UIView.animateWithDuration(0.4, animations: { () -> Void in
firstVCView.frame = CGRectOffset(firstVCView.frame, 0.0, -screenHeight)
secondVCView.frame = CGRectOffset(secondVCView.frame, 0.0, -screenHeight)
}) { (Finished) -> Void in
self.sourceViewController.presentViewController(self.storyboard.instantiateViewControllerWithIdentifier("YOUR_IDENTIFIER"),
animated: false,
completion: nil)
}
}
}
}
将 YOUR_IDENTIFIER
替换为与您的视图控制器匹配的故事板 ID。