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

Adding Motion as pod interferes with UIImagePickerController #1

Closed
theolof opened this issue Feb 10, 2017 · 9 comments
Closed

Adding Motion as pod interferes with UIImagePickerController #1

theolof opened this issue Feb 10, 2017 · 9 comments

Comments

@theolof
Copy link

theolof commented Feb 10, 2017

Motion looks like an awesome library! Playing around with it now, and noticed something.

When adding the pod the delegates of UIImagePickerControllerDelegate is not called:

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String: Any])

and

func imagePickerControllerDidCancel(_ picker: UIImagePickerController)

When removing Motion from the Podfile, the delegates work.

@daniel-jonathan
Copy link
Member

Thank you! I think Motion will be a good one :)

Can you send a sample so I can reproduce? I didn't use the UIImagePicker anywhere, but I could be overriding a delegation binding accidentally. Thank you!

@theolof
Copy link
Author

theolof commented Feb 13, 2017

OK, this was really weird.
If I do it like this:
let imagePicker = UIImagePickerController() in the class header
imagePicker.delegate = self in viewDidLoad()
it works fine without Motion in the Podfile, but not with Motion in the Podfile.

If I do it like this:

let imagePicker = UIImagePickerController()
imagePicker.delegate = self

in a local function just before I want to show the picker, it works even with Motion in the Podfile.

So, some weird stuff happened when I used Motion and had the declaration in the class header. No idea why, but it works fine with a local variable.

@theolof
Copy link
Author

theolof commented Feb 13, 2017

Too soon...it works as I described above when I start with a new project.

When I try the above in my real project, it still doesn't work with Motion in the Podfile...

No idea how you can reproduce this, since I cannot send you the whole project. I'll see if I can debug some more.

@daniel-jonathan
Copy link
Member

daniel-jonathan commented Feb 13, 2017

I looked through Motion's code and think that this maybe the issue:

Motion.swift

extension UIViewController {
    open func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return isMotionEnabled ? Motion(isPresenting: true, isContainer: false) : nil
    }
    
    open func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return isMotionEnabled ? Motion() : nil
    }
    
    open func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
        return isMotionEnabled ? MotionPresentationController(presentedViewController: presented, presenting: presenting) : nil
    }
}

Can you try taking that out and see if the issue persists? You may get another issue, but I want to know if the UIImagePickerController works correctly.

Thank you!

@theolof
Copy link
Author

theolof commented Feb 14, 2017

No, it didn't help.

However, this helps:

extension UINavigationController: UINavigationControllerDelegate {
    open override func viewDidLoad() {
        super.viewDidLoad()
        //delegate = self  <--- COMMENTED THIS LINE
    }
        @objc(navigationController:animationControllerForOperation:fromViewController:toViewController:)
    open func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return fromVC.isMotionEnabled ? Motion(isPresenting: operation == .push, isContainer: true) : nil
    }
}

@daniel-jonathan
Copy link
Member

Yes, the functions are only called when you set that value. I have an idea of how to fix it. I'll push an update to the development branch. I'll ping you when it is ready.

@daniel-jonathan
Copy link
Member

daniel-jonathan commented Feb 14, 2017

I released Motion 1.0.3, which requires a manual setting for the isMotionEnabled property by the UIImagePickerController. Give it a try and let me know :) Thank you!

@theolof
Copy link
Author

theolof commented Feb 15, 2017

Yep, it works.

@daniel-jonathan
Copy link
Member

Sweet :) Thanks for bringing this to my attention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants