0

I am using Brian Advent's video on making a blurry sidebar using the UIBlur effect (https://www.youtube.com/watch?v=qaLiZgUK2T0). However, in his video, he does not explain how to link each item of the table to a separate View Controller - he only explains how to make the single View Controller turn red. Could somebody please explain to me how to do this? The relevant code is as follows:

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")
    }
}
pkamb
  • 33,281
  • 23
  • 160
  • 191
CheezBiscuit
  • 50
  • 1
  • 9

1 Answers1

1

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

This custom SideBar is only availability on "sourceView" - a View Controller. So you can't link each item - "row of tableView" to a separate View Controller.

If you want to push to other viewControllers, you can try this:

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)
}

}

Thành Ngô Văn
  • 142
  • 3
  • 10