Skip to content

Instantly share code, notes, and snippets.

@hungdv136
Last active December 27, 2016 08:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hungdv136/d9d2dd870ab1b9eb3a919c6578827ce4 to your computer and use it in GitHub Desktop.
Save hungdv136/d9d2dd870ab1b9eb3a919c6578827ce4 to your computer and use it in GitHub Desktop.
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