Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example for using Rx extension with UIImagePickerController
let imagePicker = UIImagePickerController()
imagePicker.rx.didFinishPickingMediaWithInfo.subscribe(onNext: { [unowned self] info in
if let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage {
self.imageView.contentMode = .scaleAspectFit
self.imageView.image = pickedImage
}
self.dismiss(animated: true, completion: nil)
}).addDisposableTo(disposeBag)
imagePicker.rx.didCancel.subscribe(onNext: { [unowned self] in
print("Cancelled")
self.dismiss(animated: true, completion: nil)
}).addDisposableTo(disposeBag)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment