motion/core/device/camera.rb in bubble-wrap-1.1.4 vs motion/core/device/camera.rb in bubble-wrap-1.1.5
- old
+ new
@@ -19,21 +19,21 @@
# [:front, :rear, :none]
attr_accessor :location
def self.front
return nil if not UIImagePickerController.isCameraDeviceAvailable(UIImagePickerControllerCameraDeviceFront)
- Camera.new(:front).retain
+ @front ||= Camera.new(:front)
end
def self.rear
return nil if not UIImagePickerController.isCameraDeviceAvailable(UIImagePickerControllerCameraDeviceRear)
- Camera.new(:rear).retain
+ @rear ||= Camera.new(:rear)
end
# For uploading photos from the library.
def self.any
- Camera.new.retain
+ @any ||= Camera.new
end
def initialize(location = :none)
self.location = location
end
@@ -115,10 +115,11 @@
if source_type_readable == :camera
self.picker.cameraDevice = camera_device
end
+ presenting_controller ||= App.window.rootViewController.presentedViewController # May be nil, but handles use case of container views
presenting_controller ||= App.window.rootViewController
presenting_controller.presentViewController(self.picker, animated:@options[:animated], completion: lambda {})
end
##########
@@ -215,6 +216,6 @@
]
end
end
end
end
-::Camera = BubbleWrap::Device::Camera unless defined?(::Camera)
\ No newline at end of file
+::Camera = BubbleWrap::Device::Camera unless defined?(::Camera)