使用第三方滑块并且无法导航到另一个视图

时间:2018-04-21 02:27:18

标签: ios swift

我目前正在使用KYDrawerController作为滑块菜单而我无法导航到另一个页面。每当我按下一个按钮(即使没有代码),它也会崩溃。另一个是我试图将另一个视图设置为初始视图,它没有显示出来。我怀疑它与我的appDelegate文件有关。如果可能,我需要一些故障排除帮助。我将AppDelegate文件更改为

class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

var drawerController = KYDrawerController.init(drawerDirection: .left, drawerWidth: 300)

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    FirebaseApp.configure()

    let storyboard = UIStoryboard.init(name: "Main", bundle: Bundle.main)
    let mainVC = storyboard.instantiateViewController(withIdentifier: "MainMenu")
    let menuVC = storyboard.instantiateViewController(withIdentifier: "drawer")

    self.drawerController.mainViewController = mainVC
    self.drawerController.drawerViewController = menuVC

    self.window?.rootViewController = self.drawerController
    self.window?.makeKeyAndVisible()

    // Override point for customization after application launch.
    return true
}

这里的任何事都可能是问题?

1 个答案:

答案 0 :(得分:1)

您缺少将视图控制器嵌入navigationController。请按以下步骤更新mainVC的代码,然后重试。

let mainVC = storyboard.instantiateViewController(withIdentifier: "MainMenu")
let mainViewNavigationController = UINavigationController(rootViewController: mainVC)

self.drawerController.mainViewController = mainViewNavigationController

我希望这能解决您的问题。如果仍然面临任何问题,请告诉我。