Swift 3实现没有Storyboard的SideMenu控件(硬编码)

时间:2017-08-19 13:52:20

标签: ios iphone swift swift3

我正在尝试实施此控件:Side Menu 它说我需要在故事板中实现它:

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

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

SideMenuManager.menuLeftNavigationController = menuLeftNavigationController

AppDelegate.swift

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

    }

我现在被困在这里。谢谢你的帮助:)

1 个答案:

答案 0 :(得分:2)

FeaturedVideosController' viewDidLoad方法中,添加:

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

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