gpt4 book ai didi

ios - 来自抽屉导航的 UIViewController 之间的转换

转载 作者:行者123 更新时间:2023-11-29 00:39:06 26 4
gpt4 key购买 nike

我正在使用 Swift 3。我已经搜索过这个并找到了解决方案

navigationDrawerController?.TransitionFromRootViewController

但是当我使用这一行时,它说 TransitionFromRootViewController 不是一个函数。

所以我尝试使用

navigationDrawerController?.transition(from: RootViewController(), to: destViewController(), duration: 0.2, options: .transitionCrossDissolve, animations: nil, completion: nil)

但它显示错误:

"child view controller must have a common parent view controller when calling transitionfrom view controller"

谁能帮帮我?如果有人可以推送带有切换功能的抽屉导航的示例,那就太好了。

最佳答案

这是解决方案,我将其发布到 NavigationDrawerController example project在程序目录中, Material 2.1.2 .

它展示了如何使用多个导航 Controller 进行转换以及如何单独进行转换。

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()
}
}

您可以在GitHub issue-546中找到讨论的引用

祝一切顺利!

关于ios - 来自抽屉导航的 UIViewController 之间的转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39946182/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com