小编bax*_*axu的帖子

使用pushViewController传递数据?

使用此代码,我可以"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错误,因为新的实例化视图控制器无法读取数据.

uiviewcontroller ios segue swift

2
推荐指数
3
解决办法
6616
查看次数

标签 统计

ios ×1

segue ×1

swift ×1

uiviewcontroller ×1