Closed kbala-ami closed 8 years ago
I guess you can create your own DelegateProxy
this post could be helpful
Thanks a lot, will look into :)
Yeah, we'll also try to find time for some examples maybe.
Haven't used UIImagePickerController for a couple of years, so I'll need to check first all of the new features that were added meanwhile, and figure out is there some nice generic stateless way to wrap it :)
Hi, @kzaher do you think this is something that we should have in RxCocoa ?
I think this depends on how nicely can this be wrapped :)
The same is valid for UIAlertViewController
. They would be useful, but it is awkward to wrap them in such a way that supports all future changes and all usage scenarios.
That's why we have just an example how you can use UIAlertViewController
in example app, and not a real hardcoded public API inside RxCocoa.
The dismissal process is also little problematic [self dismissViewControllerAnimated:YES completion:NULL];
since it can be animated or not. We could figure that out when observable sequence is created, but that decision could be deferred until the end, and changed depending on picking result.
I'll need some time to figure out the optimal solution :)
Right now it looks to me that we can probably wrap UIImagePickerDelegate
inside RxCocoa, and create generic wrapping example inside example project.
This kind of reminds me of Alamofire wrapping :/
¯_(ツ)_/¯
@kzaher if you don't mind, I can spend some time and try to wrap it into something kind of RxImagePickerDelegateProxy
:)
Yep, good if someone make an example work for Camera and Photo Manipulation using RxSwift. Me too can assist if you like :)
Hi, guys.
Do you think UIImagePickerController+Rx
should have only two var
?
Kind of :
rx_didFinishPickingMediaWithInfo: Observable<[String : AnyObject]>
in this case user will need to use map
operator
rx_didCancel: Observable<Void>
Or it should also have something like:
rx_originalImage: Observable<UIImage?>
rx_editedImage: Observable<UIImage?>
Yes, It has 2 responses, Either captured or Cancelled. Hope you finished the example, let me look into now.
Is there any possible to bring Square viewfinder to capture square images?
Hi, @kbala looks like it has been merged into develop branch #387, also there is an example:)
Yes, I noticed that, Implementing that into my project :)
Hi @sergdort, it works good as expected :+1:
I know didCancel is Void observable, but the below code not called, please advise
_ = imagePickerController
.rx_didCancel
.map{ _ in
print("cancelled")
}
Hi, @kbala as far as I understand map
operator called only if there are any subscribers.
If you will do something like this:
imagePickerController.rx_didCancel
.map { _ in
print("cancel");
}.subscribeNext({ (_) -> Void in
}).addDisposableTo(disposeBag)
It will get called
Oh really, thanks a lot, I know I am still not having good understanding with Rx.
I think we can probably close this one. I've polished UIImagePicker example inside Example app a little and released 2.1.0.
Hope it's clearer now.
Hi @kzaher Now it looks simple. Cancel button not working, how to enable rx_didCancel? Please help.
Hi, @kbala are you talking about example app?
Yes, but also I implement the RxUIImagePickerController in my project, the cancel button not functioning. it should work by default.
I think the delegate for UIImagePickerController+Rx.swift
does not dismiss the image picker because the parent view controller has to dismiss the image picker.
Current Implementation:
public var rx_didCancel: Observable<()> {
return rx_delegate
.observe("imagePickerControllerDidCancel:")
.map {_ in () }
}
From the official docs:
Your delegate’s implementation of this method should dismiss the picker view by calling the dismissModalViewControllerAnimated: method of the parent view controller.
So you might have to manually call dismissViewControllerAnimated:
from your parent view controllers.
Try this:
imagePickerController.rx_didCancel
.map { _ in
print("cancel");
}.subscribeNext{ [unowned self] _ in
self.dismissViewControllerAnimated(true, completion: nil)
}.addDisposableTo(disposeBag)
Please take a look on example app, in develop branch, I guess the changes has been merged recently
Anyone suggest a best way to use UIimagePickerController for photo capturing?
Thanks a lot!