【发布时间】:2016-06-04 03:23:10
【问题描述】:
我正在尝试从嵌入在导航控制器中的视图控制器设置自定义转场。当我使用 show segue 时,一切都很好,导航栏保持不变。但是,当我尝试使用自定义 segue 类时,导航栏消失了。检查后,自定义后的 segue 视图控制器中不存在导航控制器。因此,问题似乎来自使用自定义 segue:如何使用自定义 segue 留在导航控制器中?这是我自定义的segue代码,目的是让segue有从上到下的滑动效果:
class FirstCustomSegue: UIStoryboardSegue {
override func perform() {
var firstVCView = self.sourceViewController.view as UIView!
var secondVCView = self.destinationViewController.view as UIView!
// Get the screen width and height.
let screenWidth = UIScreen.mainScreen().bounds.size.width
let screenHeight = UIScreen.mainScreen().bounds.size.height
// Specify the initial position of the destination view.
secondVCView.frame = CGRectMake(0.0, -screenHeight, screenWidth, screenHeight)
// Access the app's key window and insert the destination view above the current (source) one.
let window = UIApplication.sharedApplication().keyWindow
window?.insertSubview(secondVCView, aboveSubview: firstVCView)
// Animate the transition.
UIView.animateWithDuration(1, 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)
}
}
}
【问题讨论】:
-
这个问题和stackoverflow.com/questions/22417865/…是同一个问题,没有答案。
标签: ios swift uinavigationcontroller uistoryboardsegue