我正在尝试通过UIImagePicker将相册创建到CollectionView中,并且无法在详细的UIViewController中再次将其固定为上述照片。拔头发,这只是我刚刚开始编码的教程!
有人可以告诉我我在做什么错吗?
var testItems = [Person]()
@IBAction func addItem() {
addNewPerson()
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "DetailSegue" {
if let dest = segue.destination as? DetailsViewController,
let index = sender as? IndexPath {
dest.detailedImageHi = testItems[index.row]
}
}
}
NS对象文件如下:
class Person: NSObject {
var imageHi: String
init(imageHi: String){
self.imageHi = imageHi
}
}
DetailsViewController: 类DetailsViewController:UIViewController {
var selection: String!
var detailedImageHi: UIImage!
@IBOutlet private weak var detailsLabel: UILabel!
@IBOutlet private weak var detailedImage: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
detailsLabel.text = selection
detailedImage.image = detailedImageHi
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
import UIKit
class CollectionViewCell: UICollectionViewCell {
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var selectionImage: UIImageView!
}