0

我正在使用 Brian Advent 的视频,使用 UIBlur 效果 ( https://www.youtube.com/watch?v=qaLiZgUK2T0 ) 制作模糊的侧边栏。然而,在他的视频中,他并没有解释如何将表格的每一项链接到一个单独的 View Controller 上——他只解释了如何让单个 View Controller 变红。有人可以向我解释如何做到这一点吗?相关代码如下:

func sideBarDidSelectButtonAtIndex(index: Int) {
    if index == 0{
        imageView.backgroundColor = UIColor.whiteColor()
        imageView.image = nil
    } else if index == 1{
        imageView.backgroundColor = UIColor.clearColor()
        imageView.image = UIImage(named: "image2")
    }
}
4

1 回答 1

1

sideBar = SideBar(sourceView: self.view, menuItem: ["first item", "second item", "funny item"])

此自定义侧边栏仅在“sourceView”(视图控制器)上可用。因此,您不能将每个项目 - “tableView 行”链接到单独的视图控制器。

如果你想推送到其他 viewControllers,你可以试试这个:

func sideBarDidSelectButtonAtIndex(index: Int) {
if index == 0{
    imageView.backgroundColor = UIColor.whiteColor()
    imageView.image = nil
} else if index == 1{
    imageView.backgroundColor = UIColor.clearColor()
    imageView.image = UIImage(named: "image2")
} else if index == 2 {
    let secondVC = storyboard.instantiateViewControllerWithIdentifier("secondVC") as! secondVC
    //set some properties of secondVC here
    self.navigationController?.pushViewController(secondVC, animated: true)
}

}

于 2016-07-30T04:40:56.550 回答