gpt4 book ai didi

ios - 用另一个导航 Controller 替换当前的导航 Controller

转载 作者:行者123 更新时间:2023-11-28 06:43:13 25 4
gpt4 key购买 nike

我试过使用:

self.navigationController?.setViewControllers([anotherNavController], animated: true)

但是,我得到一个 NSException。我假设您不能在另一个中使用 UINavigationController,因为将 setViewControllers() 与普通 View Controller 一起使用可以正常工作。

我只需要关闭当前的 navigationController 并呈现另一个 navigationController,这样当新的 navigationController 被关闭时,旧的 navigationController 将不会重新出现。

我正在使用 PageMenu 这让事情变得复杂。

为什么我需要更换整个导航 Controller 的示例:

enter image description here

此代码初始化 ViewDidAppear 中的 PageMenu:

 // Initialize scroll menu
pageMenu = CAPSPageMenu(viewControllers: controllerArray, frame: CGRectMake(0.0, 0.0, self.view.frame.width, self.view.frame.height), pageMenuOptions: parameters)

self.addChildViewController(pageMenu!)
self.view.addSubview(pageMenu!.view)

pageMenu!.didMoveToParentViewController(self)

最佳答案

如果您在没有 StoryBoard 的情况下设置 PageMenu,则需要在 AppDelegate 中实例化 rootViewController。这应该消除了从默认 navigationController 切换到您自己的需求。

var window: UIWindow?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

self.window = UIWindow(frame: UIScreen.mainScreen().bounds)

self.window?.rootViewController = YourViewController(nibName: "YourViewController", bundle: nil)

self.window?.makeKeyAndVisible()

return true
}

如需在不使用 StoryBoard 的情况下设置 PageMenu 的更多帮助,请查看演示代码 here .

关于ios - 用另一个导航 Controller 替换当前的导航 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37308824/

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