ImageRow
ImageRow copied to clipboard
ImageRow example doesn't update when photo is selected
I created an empty project and use the example code for my apps view controller. When I select a photo, the image row remains blank. If I tap it again, the selected image appears. Am I missing something about how the ImageRow is supposed to work? I expected the image to update when I select it which is how it is portrayed in the animation on the github page.
Xcode: Version 11.5 beta 2 (11N605f) Eureka: 5.2.1 ImageRow 4.0
I am targeting iOS 12.4 if that matters.
Thanks for any guidance.
I'm experiencing the same issue on iOS 11. What works for me is calling self?.updateCell()
in ImageRow.swift
, for the ControllerProvider.callback { ... }, onDismiss: { ... }
, inside the onDismiss
closure.
The whole code snippet:
presentationMode = .presentModally(controllerProvider:
ControllerProvider.callback { [weak self] in
let controller = ImagePickerController()
controller.allowsEditing = self?.allowEditor ?? false
return controller
}, onDismiss: { [weak self] vc in
self?.select()
self?.updateCell()
vc.dismiss(animated: true)
})
There is also a call self?.select()
, but I'm not sure what this actually does or if it could be replaced with self?.updateCell()
.
The example works fine on iOS 13.
Im also having an issue where after picking an image from the library its value its not set on the Cell.
I tried this work around also the one in PR https://github.com/EurekaCommunity/ImageRow/pull/49
But either worked.
I found the Issue, Ironically it was caused by MY PR https://github.com/EurekaCommunity/ImageRow/pull/36 Where I Introduced the option to use the system default Image Editor.
Setting the useEditedImage
flag to True makes it use the Edited image even when it is not present. I don't remember now if the editor used to appear even for library selected images and the behaviour changed or if it was an oversight of mine.
The following snippet for the ImagePickerController.swift
makes sure to use the edited image only if its not nil, even if useEdited Image is set to true. this should clear for now. I might do a PR with that later
open func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
(row as? ImagePickerProtocol)?.imageURL = info[UIImagePickerController.InfoKey.referenceURL] as? URL
row.value = info[UIImagePickerController.InfoKey.originalImage] as? UIImage
let editedImage = info[UIImagePickerController.InfoKey.editedImage] as? UIImage
if(((row as? ImagePickerProtocol)?.useEditedImage ?? false) && editedImage != nil) {
row.value = editedImage
}
(row as? ImagePickerProtocol)?.userPickerInfo = info
onDismissCallback?(self)
}
#Update
It was not an oversight, Apple really did change the behaviour on iOS 13, and it no longer invokes the Editor when selecting from the library, but this code change should suffice either ways.