Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xcode 在Swift上向侧栏菜单添加功能_Xcode_Swift_Uiviewcontroller_Sidebar - Fatal编程技术网

Xcode 在Swift上向侧栏菜单添加功能

Xcode 在Swift上向侧栏菜单添加功能,xcode,swift,uiviewcontroller,sidebar,Xcode,Swift,Uiviewcontroller,Sidebar,所以我刚刚做了一个关于添加模糊侧边栏菜单的教程。我复制了代码,但我似乎无法找到如何调用我在故事板模式下制作的其他ViewController 我已经创建了文件并将它们链接到UIViewControllers。但是当我试图用侧边栏菜单调用ViewController时,我得到了一个黑屏 这是我过去一直关注的文件的链接 这是我跟随的youtube视频的链接 不知道为什么!任何帮助都将不胜感激 class ViewController: UIViewController, SideBarDelegat

所以我刚刚做了一个关于添加模糊侧边栏菜单的教程。我复制了代码,但我似乎无法找到如何调用我在故事板模式下制作的其他ViewController

我已经创建了文件并将它们链接到
UIViewControllers
。但是当我试图用侧边栏菜单调用ViewController时,我得到了一个黑屏

这是我过去一直关注的文件的链接 这是我跟随的youtube视频的链接

不知道为什么!任何帮助都将不胜感激

class ViewController: UIViewController, SideBarDelegate {

    var sideBar:SideBar = SideBar()         // Side Bar


    override func viewDidLoad() {
        super.viewDidLoad()


        // Side bar action and text
       sideBar = SideBar(sourceView: self.view, menuItems: ["Home", "Business Directory", "Classifieds", "Featured News", "Jobs", "Restaurants", "Sports"])
       sideBar.delegate = self

    }

    // Side Bar funcion
    func sideBarDidSelectButtonAtIndex(index: Int) {
          if index == 0{
             let vc = ViewController()
             self.presentViewController(vc, animated: true, completion: nil)
          }else if index == 1{
             let vc = businessDirectoryVC()
             self.presentViewController(vc, animated: true, completion: nil)

          }    
    }
}
将情节提要ID(在本例中为“视图”)添加到主情节提要中的视图控制器,然后将以下内容添加到要从中调用侧栏的文件中:

func sideBarDidSelectButtonAtIndex(index: Int) {

    if index == 0 {

        let storyBoard:UIStoryboard = UIStoryboard(name: "Main", bundle:nil)

        let showView = storyBoard.instantiateViewControllerWithIdentifier("view") as! ViewController

        self.presentViewController(showUebersicht, animated:true, completion:nil)

    }

}

值“0”表示侧边栏中的第一项。更改存储侧边栏项的数组的另一个值。

是否为vc设置了segue?我不这么认为,不确定segue是什么…我该怎么做?谢谢你的回复!