Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/camera-plus.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ export class MySwifty extends SwiftyCamViewController {
}

public closePicker() {
rootVC().dismissViewControllerAnimatedCompletion(true, () => {
this.getParentViewController().dismissViewControllerAnimatedCompletion(true, () => {
this.pickerDelegate = null;
});
}
Expand Down Expand Up @@ -572,6 +572,15 @@ export class MySwifty extends SwiftyCamViewController {
return UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera);
}

public getParentViewController() {
var responder: UIResponder = this.view;
do {
responder = responder.nextResponder;
} while (responder && !(NSStringFromClass(responder.class()) === 'UIViewControllerImpl'));

return <UIViewController>responder;
}

public chooseFromLibrary(options?: IChooseOptions): Promise<any> {
return new Promise((resolve, reject) => {
this._pickerDelegate = null;
Expand Down Expand Up @@ -636,7 +645,7 @@ export class MySwifty extends SwiftyCamViewController {

imagePickerController.mediaType = mediaType;

rootVC().presentViewControllerAnimatedCompletion(imagePickerController, true, null);
this.getParentViewController().presentViewControllerAnimatedCompletion(imagePickerController, true, null);
});
}

Expand Down Expand Up @@ -932,10 +941,6 @@ export class CameraPlus extends CameraPlusBase {
}
}

const rootVC = function() {
const appWindow = UIApplication.sharedApplication.keyWindow;
return appWindow.rootViewController;
};

const createButton = function(
target: any,
Expand Down