I have programmed a UICollectionView and when the cell is select I would like for it to go to another view cotroller. I am getting the error message of
Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value.
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let vc = storyboard?.instantiateViewController(withIdentifier: "twoVC") as? twoVC
self.navigationController?.pushViewController(vc!, animated: true)
//Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value
}
}
class twoVC : UIViewController {
@IBOutlet var label : UILabel!
@IBOutlet var photo : UIImageView!
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.