【发布时间】:2015-05-01 04:15:00
【问题描述】:
我有一个这样的容器视图:
主程序称为 ConfigViewContainer,子程序称为 ConfigDistrictViewController,上面有一个 UIPicker。 如果我没有在情节提要 ConfigDistrictViewController 中设置为隐藏,那么它会显示。
现在我想在 ConfigViewController 文本字段控件中执行触地事件时通过代码显示它。
var configDistrictViewController: ConfigDistrictViewController?
var uiView : UIView?
@IBAction func selectDistrictTouchDown(sender: AnyObject) {
self.performSegueWithIdentifier("ConfigDistrictSelectionSegue", sender: self)
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if(segue.identifier == "ConfigDistrictViewController")
{
configDistrictViewController = segue.destinationViewController as? ConfigDistrictViewController
configDistrictViewController?.showContainer()
// Also tried the following
uiView = configDistrictViewController?.view
uiView?.hidden = false
}
}
这是 ConfigDistrictViewController 中的代码:
func showContainer()
{
println("showContainer")
self.view.hidden = true
}
但我得到的只是这样的错误:
失败发生在这里:
configDistrictViewController = segue.destinationViewController as? ConfigDistrictViewController
所以我想我可能会使用:
self.performSegueWithIdentifier("ConfigDistrictSelectionSegue", sender: self)
不正确
【问题讨论】: