[英]transition between UIViewController from navigation drawer
I am Using Swift 3. I have searched about this and found the solution 我正在使用Swift3。我已经对此进行了搜索并找到了解决方案
navigationDrawerController?.TransitionFromRootViewController
but when I used this line it say TransitionFromRootViewController
is not a function. 但是当我使用这一行时,它说TransitionFromRootViewController
不是一个函数。
So I tried Using 所以我尝试使用
navigationDrawerController?.transition(from: RootViewController(), to: destViewController(), duration: 0.2, options: .transitionCrossDissolve, animations: nil, completion: nil)
but it shows error that the: 但显示以下错误:
"child view controller must have a common parent view controller when calling transitionfrom view controller" “从视图控制器调用transition时,子视图控制器必须具有一个公共的父视图控制器”
Can anyone help me please? 谁能帮我吗? If someone can push an example of navigation drawer with the switching would be a great. 如果有人可以推动一个带有开关的导航抽屉示例,那就太好了。
Here is the solution, which I posted to the NavigationDrawerController example project in the programmatic directory, Material 2.1.2 . 这是解决方案,我将其发布到程序设计目录Material 2.1.2中的NavigationDrawerController示例项目中。
It shows how to transition with multiple navigation controllers, and by itself. 它显示了如何与多个导航控制器及其自身进行过渡。
import UIKit
import Material
class LeftViewController: UIViewController {
private var transitionButton: FlatButton!
open override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = Color.blue.base
prepareTransitionButton()
}
@objc
internal func handleTransitionButton() {
// Transition the entire NavigationDrawer rootViewController.
// navigationDrawerController?.transition(to: TransitionedViewController(), completion: closeNavigationDrawer)
// Transition the ToolbarController rootViewController that is in the
// NavigationDrawer rootViewController.
(navigationDrawerController?.rootViewController as? ToolbarController)?.transition(to: TransitionedViewController(), completion: closeNavigationDrawer)
}
internal func closeNavigationDrawer(result: Bool) {
navigationDrawerController?.closeLeftView()
}
private func prepareTransitionButton() {
transitionButton = FlatButton(title: "Transition VC", titleColor: Color.white)
transitionButton.addTarget(self, action: #selector(handleTransitionButton), for: .touchUpInside)
view.layout(transitionButton).horizontally().center()
}
}
You can find a reference to the discussion in GitHub issue-546 您可以在GitHub issue-546中找到有关讨论的参考
All the best! 祝一切顺利!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.