From ce3dfb29a8de45848670ade7da0c6210521006a4 Mon Sep 17 00:00:00 2001 From: Nedyalko Nikolov Date: Tue, 28 Apr 2015 11:57:11 +0300 Subject: [PATCH] Fixed null pointer while using camera for ios. --- camera/camera.ios.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/camera/camera.ios.ts b/camera/camera.ios.ts index e282166f0..55accf40b 100644 --- a/camera/camera.ios.ts +++ b/camera/camera.ios.ts @@ -60,17 +60,21 @@ class UIImagePickerControllerDelegateImpl extends NSObject implements UIImagePic } } picker.presentingViewController.dismissViewControllerAnimatedCompletion(true, null); + listener = null; } imagePickerControllerDidCancel(picker): void { picker.presentingViewController.dismissViewControllerAnimatedCompletion(true, null); + listener = null; } } +var listener; + export var takePicture = function (options?: definition.CameraOptions): Promise { return new Promise((resolve, reject) => { + listener = null; var imagePickerController = new UIImagePickerController(); - var listener = null; var reqWidth = 0; var reqHeight = 0; var keepAspectRatio = true; @@ -99,8 +103,7 @@ export var takePicture = function (options?: definition.CameraOptions): Promise< if (topMostFrame) { var viewController: UIViewController = topMostFrame.currentPage && topMostFrame.currentPage.ios; if (viewController) { - - viewController.presentModalViewControllerAnimated(imagePickerController, true); + viewController.presentViewControllerAnimatedCompletion(imagePickerController, true, null); } } });