Skip to content

Commit

Permalink
Merge pull request #253 from NativeScript/tbozhikov/fix-ios-delegate
Browse files Browse the repository at this point in the history
fix: set ios delegate as late as possible, so that the native UI always hooks to its methods correctly
  • Loading branch information
tbozhikov authored Feb 26, 2019
2 parents 27dbb5d + 2a13773 commit e8fd440
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/imagepicker.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@ export class ImagePicker extends data_observable.Observable {
super();

this._hostView = hostView;
this._imagePickerControllerDelegate = new ImagePickerControllerDelegate();
this._imagePickerControllerDelegate = ImagePickerControllerDelegate.new();

let imagePickerController = QBImagePickerController.alloc().init();
imagePickerController.assetCollectionSubtypes = defaultAssetCollectionSubtypes;
imagePickerController.mediaType = options.mediaType ? <QBImagePickerMediaType>options.mediaType.valueOf() : QBImagePickerMediaType.Any;
imagePickerController.delegate = this._imagePickerControllerDelegate;
imagePickerController.allowsMultipleSelection = options.mode !== 'single';
imagePickerController.minimumNumberOfSelection = options.minimumNumberOfSelection || 0;
imagePickerController.maximumNumberOfSelection = options.maximumNumberOfSelection || 0;
Expand Down Expand Up @@ -80,7 +79,9 @@ export class ImagePicker extends data_observable.Observable {
this._imagePickerControllerDelegate._resolve = resolve;
this._imagePickerControllerDelegate._reject = reject;

this.hostController.presentViewControllerAnimatedCompletion(this._imagePickerController, true, null);
this.hostController.presentViewControllerAnimatedCompletion(this._imagePickerController, true, () => {
this._imagePickerController.delegate = this._imagePickerControllerDelegate;
});
});
}
}
Expand Down Expand Up @@ -129,4 +130,3 @@ export class ImagePickerControllerDelegate extends NSObject implements QBImagePi
export function create(options?: Options, hostView?: View): ImagePicker {
return new ImagePicker(options, hostView);
}

0 comments on commit e8fd440

Please sign in to comment.