如何将SWRevealviewcontroller库用于多个视图控制器

时间:2018-11-05 10:41:38

标签: ios swift

我已经使用过SWrevealviewcontroller来创建我的侧边菜单,并且它已经成功运行,但是当我将它用于其他视图控制器来进行另一个边菜单时,它会产生一个问题 问题是

  

“视图控制器”是无法访问的,因为它没有入口点,也没有用于通过-[UIStoryboard InstantiateViewControllerWithIdentifier:]进行运行时访问的标识符

1 个答案:

答案 0 :(得分:0)

extension UIViewController {

func SetREvealviewcontroller(ControllerIdentifier:String,storyboardname:String) -> Void
{
let storyboard = UIStoryboard(name: storyboardname, bundle: nil)
let frontNavigationController:UINavigationController
let rearNavigationController:UINavigationController
let revealController = SWRevealViewController()
var mainRevealController = SWRevealViewController()



let sidebar = storyboard.instantiateViewController(withIdentifier:  "MenuViewController")as! MenuViewController
let homepage = storyboard.instantiateViewController(withIdentifier: ControllerIdentifier)

frontNavigationController =  UINavigationController(rootViewController: homepage)
rearNavigationController = UINavigationController(rootViewController: sidebar)
frontNavigationController.navigationBar.backgroundColor = UIColor.init(rgb:0x03253d)
frontNavigationController.navigationBar.barTintColor = UIColor.init(rgb:0x03253d)


revealController.frontViewController = frontNavigationController
revealController.rearViewController = rearNavigationController


frontNavigationController.navigationBar.isTranslucent = false




mainRevealController  = revealController

appDelegate.window?.rootViewController = mainRevealController
}