Sha256: f392ee24aef9591086fe1692dfb99f3c54409d52a2d64ab1004955027596f0a0
Contents?: true
Size: 979 Bytes
Versions: 1
Compression:
Stored size: 979 Bytes
Contents
# # A little module to wrap up the built-in # iOS images picking/taking # class UnderOs::Image::Picker def initialize(options={}) @animated = options.delete(:animated) || true @_ = UIImagePickerController.alloc.init @_.delegate = self end def take(&block) if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceTypeCamera) @_.setSourceType(UIImagePickerControllerSourceTypeCamera) start(&block) else pick(&block) end end def pick(&block) @_.setSourceType(UIImagePickerControllerSourceTypePhotoLibrary) start(&block) end def start(&block) @block = block @page = UnderOs::App.history.current_page._ @page.presentViewController @_, animated: @animated, completion: nil end def imagePickerController(picker, didFinishPickingImage:image, editingInfo:info) @page.dismissModalViewControllerAnimated(@animated) @block.call(UnderOs::Image.new(image)) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
under-os-image-1.0.0 | lib/under_os/image/picker.rb |