使用此代码,我可以"segue"到我的视图控制器的同一个实例
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "DetailVC")
self.navigationController?.pushViewController(vc, animated: true)
}
Run Code Online (Sandbox Code Playgroud)
但是,如何传递数据?我只知道如何使用segue选项传递数据.当我用这个运行代码时,我得到nil错误,因为新的实例化视图控制器无法读取数据.