在第一个视图控制器中,我们有两个按钮
如果我们点击第一个视图控制器oneButn
,我需要在第二个视图控制器中隐藏onebutnContainerView
如果我们点击第一个视图控制器secndButn
,我需要在第二个视图控制器中隐藏twobutnContainerView
在第一视图控制器viewController.oneButnContainerView.isHidden = true
中出现错误:
线程1:致命错误:意外地发现nil,同时隐式展开一个可选值
第一视图控制器代码:
class firstViewController: UIViewController{
@IBAction func oneButn(_ sender: UIButton) {
self.view.endEditing(true)
let viewController = self.storyboard?.instantiateViewController(withIdentifier: "NewZoomAddressViewController") as! NewZoomAddressViewController;
viewController.delegate = self
viewController.oneButnContainerView.isHidden = true
viewController.twobutnContainerView.isHidden = false
self.navigationController?.pushViewController(viewController, animated: true);
}
@IBAction func secndButn(_ sender: UIButton) {
self.view.endEditing(true)
let viewController = self.storyboard?.instantiateViewController(withIdentifier: "NewZoomAddressViewController") as! NewZoomAddressViewController;
viewController.delegate = self
viewController.oneButnContainerView.isHidden = false
viewController.twobutnContainerView.isHidden = true
self.navigationController?.pushViewController(viewController, animated: true);
}
}
我在第二个视图控制器中有两个视图的插座
@IBOutlet weak var oneButnContainerView: UIView!
@IBOutlet weak var twoButnContainerView: UIView!
如何在firstviewcontroller中隐藏seconviewcontroller视图