Merge pull request #88 from NativeScript/nnikolov/CameraIssuesIos

Fixed null pointer while using camera for ios.
This commit is contained in:
Nedyalko Nikolov
2015-04-28 12:13:55 +03:00

View File

@ -60,17 +60,21 @@ class UIImagePickerControllerDelegateImpl extends NSObject implements UIImagePic
} }
} }
picker.presentingViewController.dismissViewControllerAnimatedCompletion(true, null); picker.presentingViewController.dismissViewControllerAnimatedCompletion(true, null);
listener = null;
} }
imagePickerControllerDidCancel(picker): void { imagePickerControllerDidCancel(picker): void {
picker.presentingViewController.dismissViewControllerAnimatedCompletion(true, null); picker.presentingViewController.dismissViewControllerAnimatedCompletion(true, null);
listener = null;
} }
} }
var listener;
export var takePicture = function (options?: definition.CameraOptions): Promise<imageSource.ImageSource> { export var takePicture = function (options?: definition.CameraOptions): Promise<imageSource.ImageSource> {
return new Promise<imageSource.ImageSource>((resolve, reject) => { return new Promise<imageSource.ImageSource>((resolve, reject) => {
listener = null;
var imagePickerController = new UIImagePickerController(); var imagePickerController = new UIImagePickerController();
var listener = null;
var reqWidth = 0; var reqWidth = 0;
var reqHeight = 0; var reqHeight = 0;
var keepAspectRatio = true; var keepAspectRatio = true;
@ -99,8 +103,7 @@ export var takePicture = function (options?: definition.CameraOptions): Promise<
if (topMostFrame) { if (topMostFrame) {
var viewController: UIViewController = topMostFrame.currentPage && topMostFrame.currentPage.ios; var viewController: UIViewController = topMostFrame.currentPage && topMostFrame.currentPage.ios;
if (viewController) { if (viewController) {
viewController.presentViewControllerAnimatedCompletion(imagePickerController, true, null);
viewController.presentModalViewControllerAnimated(imagePickerController, true);
} }
} }
}); });