【发布时间】:2019-09-14 22:05:45
【问题描述】:
所以我有一个可以从相机创建的图像,我想将它传输到另一个类,它的类型为 UIImage,其中已经有一些东西。该数组连接到 UICollectionView。
我不知道该怎么做我仍然知道 swift 和一般的编程,但我只是喜欢学习。如果有人有任何建议,我将不胜感激。
这是collectionView的功能
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as! DiscoverCollectionViewCell
cell.titleLable.text = Stuff[indexPath.item]
cell.imageView.image = stuffImages[indexPath.item]
return cell
}
下面是我创建的数组
let stuffImages : [UIImage] = [
UIImage(named: "1")!,
UIImage(named: "2")!,
UIImage(named: "3")!,]
这是我徒劳的尝试在另一个班级
var discover = MainViewController()
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
let image = info[UIImagePickerController.InfoKey.originalImage] as! UIImage
imageCam.image = image
discover.stuffImages[]
picker.dismiss(animated: true, completion: nil)
}
我只是迷路了,非常感谢您的帮助,谢谢
【问题讨论】:
-
这两个类是如何关联的?
-
with --> var discover = MainViewController()
-
另一个类叫做CamViewController
-
您是否希望将图像附加到现有数组中
-
是的,来自另一个班级
标签: arrays swift function class