我一直在关注如何实现自定义segues的教程。使用滑动手势 - 我滑动我的手指segue工作但不是平滑过渡,第二个ViewController向上/向下滑动以替换当前的一个,我得到一个黑屏然后目标ViewController加载..
这在前进和后退segue上都会发生。
我已经附加了正常segue的动画代码(不是倒带)。
另外,当我轻轻地滑动屏幕时,瞬间发生了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)
}
}
}
}
答案 0 :(得分:1)
尝试此代码,我更改了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。