美文网首页
多个 storyboard 页面跳转

多个 storyboard 页面跳转

作者: Mr_滑 | 来源:发表于2023-02-02 16:06 被阅读0次

一个项目可以不止一个 storyboard 文件,它们间也可以互相调用。假如还添加一个 Second.storyboard,里面的 View Controller 设置 identity 为 SecondView,则我们可以通过导航的方式来关联两个 storyboard 文件。
(1)在 AppDelegate 的 Application 入口里把Main面板放入导航控制:

let rootViewController = UIStoryboard(name: "Main", bundle: nil)
    .instantiateInitialViewController()!
self.window!.rootViewController = UINavigationController(rootViewController:
    rootViewController)

(2)然后可以在 RootView 里放入一个按钮,点击事件里导航到 Second 面板:

let viewController = UIStoryboard(name: "Second", bundle: nil)
    .instantiateViewController(withIdentifier: "SecondView") as UIViewController
self.navigationController?.pushViewController(viewController, animated: true)

原文出自:www.hangge.com 转载请保留原文链接:https://www.hangge.com/blog/cache/detail_635.html

相关文章

网友评论

      本文标题:多个 storyboard 页面跳转

      本文链接:https://www.haomeiwen.com/subject/ietghdtx.html