ios - 如何为多个 View Controller 使用 SWRevealviewcontroller 库

标签 ios swift

我已经使用 SWrevealviewcontroller 来制作我的侧边菜单并且它工作成功,但是当我将它用于不同的 View Controller 来制作另一个侧边菜单时它会出现问题 问题是

“View Controller“ is unreachable because it has no entry points and no identifier for runtime access via -[UIStoryboard instantiateViewControllerWithIdentifier:]

最佳答案

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
}

关于ios - 如何为多个 View Controller 使用 SWRevealviewcontroller 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53152773/

相关文章:

ios - NSURLConnection如何获取剩余时间信息

objective-c - 触发 IBAction 或在虚拟键盘中点击 Go/Enter 按钮的方法

android - Android-> iOS零配置网络发现jmDNS损坏

ios - 将 UIView 放置在导航栏前面时看不到按钮

ios - UITableView 需要长按选择一行

ios - 文本中只允许 2 个空格

ios - 改变ios导航栏的高度

swift - 描述或使用字符串来解释 UIColor

Swift Array - 检查索引是否存在

ios - 按下按钮时如何更改角标(Badge)编号?