ios - Swift 3 在没有 Storyboard 的情况下实现 SideMenu 控件(硬编码)

标签 ios iphone swift swift3

我正在尝试实现此控件:Side Menu 它说我需要在 Storyboard中实例化它:

let menuLeftNavigation = Controllerstoryboard!.instantiateViewController(withIdentifier: "LeftMenuNavigationController") as! UISideMenuNavigationController

但是我没有 Storyboard,我已经创建了一个 UINavigationController(见下文)以便我可以使用该模块:

SideMenuManager.menuLeftNavigationController = menuLeftNavigationController

AppDelegate.swift

didFinishLaunchingWithOptions {
        let layout = UICollectionViewFlowLayout()
        let featuredVideosController = FeaturedVideosController(collectionViewLayout: layout)
        window?.rootViewController = UINavigationController(rootViewController:featuredVideosController) //Required

    }

我目前被困在这里。感谢您的帮助:)

最佳答案

FeaturedVideosControllerviewDidLoad方法中,添加:

let menuLeftNavigationController = UISideMenuNavigationController(rootViewController: YourMenuContentViewController)
menuLeftNavigationController.leftSide = true
SideMenuManager.menuLeftNavigationController = menuLeftNavigationController

Side Menu 中查看更多详细信息的代码实现部分。

关于ios - Swift 3 在没有 Storyboard 的情况下实现 SideMenu 控件(硬编码),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45772360/

相关文章:

ios - 如何在代码中获取我的 iOS 项目的当前版本?

ios - 将 UICollectionView 的选定索引路径存储在 UITableView 中

javascript - 是否有适用于 iPhone 的 JQuery 插件可以通知用户其应用程序 "Bookmark"?

iphone - 如何在 iphone 中制作像 pop 这样的动画而不是 push

ios - 无法从测试目标中看到 Swift 类

ios - 无法确定 UIImageView 帧何时相等

iphone - 如何知道iPhone何时丢失或重新获得互联网连接?

ios - UICollectionView 两个具有相同 View 的单元格。第二个单元格什么也没显示

ios - 仅显示具有正确电话号码的联系人(联系人框架)

ios - 如何让这个 segue 动画退出到右侧或左侧? - swift