用切换botton显示SWReveal的前视图控制器

时间:2019-02-26 12:58:27

标签: swift swrevealviewcontroller

我有一个正在使用SWreveal的应用程序,并且在前View控制器中还有一个bottomSheet。我必须以编程方式打开视图控制器才能使底部工作,而现在的问题是如果我有这样的代码

let storyboard = R.storyboard.baseSB()

            let swVC = storyboard.instantiateViewController(withIdentifier: SWRevealViewController.className) as! SWRevealViewController

            swVC.loadView()

            let homeVC = swVC.frontViewController as! HomeVC

            homeVC.mode = AppMode.go
            let bottomSheetVC = BottomSheetVC(contentViewController: swVC, drawerViewController: UIViewController())
            bottomSheetVC.drawerCornerRadius = 0
            bottomSheetVC.initialDrawerPosition = .closed
            bottomSheetVC.shadowRadius = 0
            bottomSheetVC.shadowOpacity = 0

            homeVC.bottomDrawer = bottomSheetVC
            bottomSheetVC.modalTransitionStyle = .crossDissolve

            self?.present(bottomSheetVC, animated: true, completion: nil)

一切都与侧抽屉一起使用,我可以切换视图控制器,但bottomSheet无法正常工作,像这样传递它,使bottoSheet可以工作,但是如果我单击切换按钮,应用程序将崩溃

let storyboard = R.storyboard.baseSB()

let swVC = storyboard.instantiateViewController(withIdentifier: SWRevealViewController.className) as! SWRevealViewController

swVC.loadView()
storyboard.instantiateViewController(withIdentifier: HomeVC.className) as! HomeVC

let homeVC = swVC.frontViewController as! HomeVC

homeVC.mode = AppMode.go
let bottomSheetVC = BottomSheetVC(contentViewController: homeVC, drawerViewController: UIViewController())
bottomSheetVC.drawerCornerRadius = 0
bottomSheetVC.initialDrawerPosition = .closed
bottomSheetVC.shadowRadius = 0
bottomSheetVC.shadowOpacity = 0

homeVC.bottomDrawer = bottomSheetVC
bottomSheetVC.modalTransitionStyle = .crossDissolve

self?.present(bottomSheetVC, animated: true, completion: nil)

如何解决此问题,以便在切换侧视图控制器按钮时应用程序不会崩溃

0 个答案:

没有答案