简体   繁体   English

导航抽屉中的UIViewController之间的过渡

[英]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.

相关问题 从UIViewController过渡到另一个 - Transition from UIViewController to Another 从UIViewController过渡到TabBarViewController - Transition from UIViewController to TabBarViewController 从SKScene过渡到UIViewcontroller - Transition from SKScene to UIViewcontroller 从UIViewController导航到Appdelegate - Navigation From UIViewController to Appdelegate 如何从UIViewController过渡到UINavigationController - How to transition to a UINavigationController from a UIViewController 在UIViewController和UITabBarViewController之间添加过渡效果 - Adding a transition effect between the UIViewController and UITabBarViewController 自定义UIStoryboardSegue和UIViewController过渡之间的区别 - Difference between a custom UIStoryboardSegue and UIViewController transition 从UICollectionViewController导航到UIViewController时,UIViewController闪烁 - Blinking of UIViewController while navigation from UICollectionViewController to UIViewController 导航控制器之间的自定义过渡 - Custom Transition Between Navigation Controllers 如何实现从UICollectionViewController到UIViewController的自定义UIViewController转换? - How can I achieve this custom UIViewController Transition from UICollectionViewController to UIViewController?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM