<分区>
我正在尝试以编程方式显示不同 Storyboard的我的一个 ViewControllers
。但由于某些原因,我试图显示的 ViewController
的属性为零。
那是我的错误:在展开可选值时意外发现 nil
I'm getting the error in my
SecondViewController
. It is showing but my app crashes due to the properties being nil.
这是我的代码:
let secondStoryBoard = UIStoryboard(name: "SecondStoryBoard", bundle: nil)
let secondViewController = secondStoryBoard.instantiateViewController(withIdentifier: "secondVC") as! SecondVC
self.navigationController?.pushViewController(secondViewController, animated: true)
这是产生错误的代码:
class SecondVC: ViewController
{
@IBOutlet weak var mapView: MKMapView!
mapView.isHidden = true // ERROR!! Unexpectedly found nil while unwrapping an Optional value
}
SOLVED: just had to reconnect my
@IBOutlet
connections