Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImageRow example doesn't update when photo is selected #83

Open
vincenzon opened this issue May 17, 2020 · 3 comments
Open

ImageRow example doesn't update when photo is selected #83

vincenzon opened this issue May 17, 2020 · 3 comments

Comments

@vincenzon
Copy link

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.

@eelcokoelewijn
Copy link

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.

@joaodforce
Copy link
Contributor

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 #49

But either worked.

@joaodforce
Copy link
Contributor

joaodforce commented Jul 24, 2020

I found the Issue, Ironically it was caused by MY PR #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.

joaodforce added a commit to joaodforce/ImageRow that referenced this issue Oct 19, 2020
mats-claassen pushed a commit that referenced this issue Oct 21, 2020
* Fixes for #83 and #82

* Chaged it so row.value is set only Once
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants