当我从一个视图控制器展开到另一个作为选项卡栏控制器 child 的视图控制器时,如何显示选项卡栏控制器?
How can I show the tab bar controller when I unwind from a view controller to another view controller that's a child of the tab bar controller?
我有一个标签栏控制器和其中的 3 个 child,我还有另一个视图,我自定义了从 child 到视图控制器的转场,还有一个自定义从视图控制器展开 segue 到 child。问题是在展开时,标签栏是隐藏的,它会在展开完成时显示。
这是一个 GIF 示例:
这是我的自定义转场展开代码:
import UIKit
class AddMeCustomSegueUnwind: UIStoryboardSegue {
override func perform() {
// Assign the source and destination views to local variables.
let secondVCView = self.sourceViewController.view as UIView!
let firstVCView = self.destinationViewController.view as UIView!
let screenHeight = UIScreen.mainScreen().bounds.size.height
let window = UIApplication.sharedApplication().keyWindow
//window?.insertSubview(firstVCView, aboveSubview: secondVCView)
//window?.insertSubview(firstVCView, belowSubview: secondVCView)
window?.insertSubview(firstVCView, atIndex: 0)
// Animate the transition.
UIView.animateWithDuration(0.4, animations: { () -> Void in
secondVCView.frame = CGRectOffset(secondVCView.frame, 0.0, -screenHeight + 64)
}) { (Finished) -> Void in
self.sourceViewController.dismissViewControllerAnimated(false, completion: nil)
}
}
}
为了像我说的那样进行展开,需要从选项卡栏控制器完成展开转场,所以我创建了一个 UITabBarController
并向其中添加了相同的展开。
我有一个标签栏控制器和其中的 3 个 child,我还有另一个视图,我自定义了从 child 到视图控制器的转场,还有一个自定义从视图控制器展开 segue 到 child。问题是在展开时,标签栏是隐藏的,它会在展开完成时显示。
这是一个 GIF 示例:
这是我的自定义转场展开代码:
import UIKit
class AddMeCustomSegueUnwind: UIStoryboardSegue {
override func perform() {
// Assign the source and destination views to local variables.
let secondVCView = self.sourceViewController.view as UIView!
let firstVCView = self.destinationViewController.view as UIView!
let screenHeight = UIScreen.mainScreen().bounds.size.height
let window = UIApplication.sharedApplication().keyWindow
//window?.insertSubview(firstVCView, aboveSubview: secondVCView)
//window?.insertSubview(firstVCView, belowSubview: secondVCView)
window?.insertSubview(firstVCView, atIndex: 0)
// Animate the transition.
UIView.animateWithDuration(0.4, animations: { () -> Void in
secondVCView.frame = CGRectOffset(secondVCView.frame, 0.0, -screenHeight + 64)
}) { (Finished) -> Void in
self.sourceViewController.dismissViewControllerAnimated(false, completion: nil)
}
}
}
为了像我说的那样进行展开,需要从选项卡栏控制器完成展开转场,所以我创建了一个 UITabBarController
并向其中添加了相同的展开。