Skip to content

Commit e8fd440

Browse files
authored
Merge pull request #253 from NativeScript/tbozhikov/fix-ios-delegate
fix: set ios delegate as late as possible, so that the native UI always hooks to its methods correctly
2 parents 27dbb5d + 2a13773 commit e8fd440

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/imagepicker.ios.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,11 @@ export class ImagePicker extends data_observable.Observable {
4343
super();
4444

4545
this._hostView = hostView;
46-
this._imagePickerControllerDelegate = new ImagePickerControllerDelegate();
46+
this._imagePickerControllerDelegate = ImagePickerControllerDelegate.new();
4747

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

83-
this.hostController.presentViewControllerAnimatedCompletion(this._imagePickerController, true, null);
82+
this.hostController.presentViewControllerAnimatedCompletion(this._imagePickerController, true, () => {
83+
this._imagePickerController.delegate = this._imagePickerControllerDelegate;
84+
});
8485
});
8586
}
8687
}
@@ -129,4 +130,3 @@ export class ImagePickerControllerDelegate extends NSObject implements QBImagePi
129130
export function create(options?: Options, hostView?: View): ImagePicker {
130131
return new ImagePicker(options, hostView);
131132
}
132-

0 commit comments

Comments
 (0)