【问题标题】:Connecting a View Controller to a Sidebar in Xcode在 Xcode 中将视图控制器连接到侧边栏
【发布时间】:2016-07-30 01:35:53
【问题描述】:

我正在使用 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")
    }
}

【问题讨论】:

    标签: ios swift xcode uiblureffect


    【解决方案1】:

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

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

    如果你想push到其他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)
    }
    

    }

    【讨论】:

    • 请详细说明 - 我无法设置 secondVC 的属性
    • ex: secondVC.title = "这是第二个视图控制器标题" secondVC.var1 = 100 ...
    猜你喜欢
    • 2016-07-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-19
    • 1970-01-01
    • 1970-01-01
    • 2013-02-19
    • 1970-01-01
    相关资源
    最近更新 更多