gpt4 book ai didi

ios - 如何在 Swift 中显示带有 UICollectionView 的弹出 UIViewController?

转载 作者:行者123 更新时间:2023-11-30 12:41:44 25 4
gpt4 key购买 nike

如果我从 Storyboard启动它,带有 UICollectionView 的 UIViewController 工作正常。但是,当我尝试像这样启动它时:

let imagePicker = imagePickerControllerViewController()
imagePicker.modalPresentationStyle = .OverCurrentContext
presentViewController(imagePicker, animated: true, completion: nil)

在线崩溃:

collectionView.dataSource = self

问题是,如何正确地显示 UIViewController(具有 UICollectionView)?

最佳答案

替换:

let imagePicker = imagePickerControllerViewController()

与:

let imagePicker = storyboard.instantiateViewControllerWithIdentifier("imagePicker") as! imagePickerControllerViewController

关于ios - 如何在 Swift 中显示带有 UICollectionView 的弹出 UIViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42165383/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com