Hi,
I have an UICollecitonView that loads a placeholder image within a ColletionView cell without any problems. The placeholder image is loaded via ‘Assets’ using a string property.
class SampleImageView: UIImageView {
let placeholderImage = UIImage(named: "Sample")
override init(frame: CGRect) {
super.init(frame: frame)
configure()
}
''''
func setImage(holder: UIImage) {
image = holder
}
private func configure() {
layer.cornerRadius = 10
clipsToBounds = true
image = placeholderImage
translatesAutoresizingMaskIntoConstraints = false
}
}
In addition, I would like to replace the placeholder image with the one taking via the camera. I know that the image from the camera is loading without any any problems.
private func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
picker.dismiss(animated: true)
guard let image = info[.editedImage] as? UIImage else {
print("No image found")
return
}
imageTaken = true
placeHolderImage.contentMode = .center
placeHolderImage.image = resizeImage(image: image, targetSize: CGSize(width: 44, height: 44))
}
And then from my CollectionView VC:
extension SampleCollectionVC: SampleMoveDataDelegate {
func didTapAdd(data: SampleData) {
// Verify that the VC is getting the image passed to it.
let photoSize = data.sampleImage?.size.width
print(photoSize)
The collecitonView loads fine, but the placeholder image is displayed and not the camera image. Also fYI, I am applying the datasource snapshot on the main thread. And finally, here's the data struct:
struct SampleData: Hashable {
var sampleName: String // Perscription name
var sampleImage: UIImage?
}
Does anyone have any recommendations to handle this situation?
Thanks,
I have an UICollecitonView that loads a placeholder image within a ColletionView cell without any problems. The placeholder image is loaded via ‘Assets’ using a string property.
class SampleImageView: UIImageView {
let placeholderImage = UIImage(named: "Sample")
override init(frame: CGRect) {
super.init(frame: frame)
configure()
}
''''
func setImage(holder: UIImage) {
image = holder
}
private func configure() {
layer.cornerRadius = 10
clipsToBounds = true
image = placeholderImage
translatesAutoresizingMaskIntoConstraints = false
}
}
In addition, I would like to replace the placeholder image with the one taking via the camera. I know that the image from the camera is loading without any any problems.
private func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
picker.dismiss(animated: true)
guard let image = info[.editedImage] as? UIImage else {
print("No image found")
return
}
imageTaken = true
placeHolderImage.contentMode = .center
placeHolderImage.image = resizeImage(image: image, targetSize: CGSize(width: 44, height: 44))
}
And then from my CollectionView VC:
extension SampleCollectionVC: SampleMoveDataDelegate {
func didTapAdd(data: SampleData) {
// Verify that the VC is getting the image passed to it.
let photoSize = data.sampleImage?.size.width
print(photoSize)
Code Block // Append data then retake if LoadData.shared.getPerscriptionData().isEmpty { LoadData.shared.update(perscription: medicaiton) configureViewController() configureCollectionView() configureDataSource() updateData() DispatchQueue.main.async { self.collectionView.reloadData() }
}The collecitonView loads fine, but the placeholder image is displayed and not the camera image. Also fYI, I am applying the datasource snapshot on the main thread. And finally, here's the data struct:
struct SampleData: Hashable {
var sampleName: String // Perscription name
var sampleImage: UIImage?
}
Does anyone have any recommendations to handle this situation?
Thanks,