@@ -236,7 +236,7 @@ export class MySwifty extends SwiftyCamViewController {
236
236
}
237
237
238
238
public closePicker ( ) {
239
- rootVC ( ) . dismissViewControllerAnimatedCompletion ( true , ( ) => {
239
+ this . getParentViewController ( ) . dismissViewControllerAnimatedCompletion ( true , ( ) => {
240
240
this . pickerDelegate = null ;
241
241
} ) ;
242
242
}
@@ -450,6 +450,15 @@ export class MySwifty extends SwiftyCamViewController {
450
450
return UIImagePickerController . isSourceTypeAvailable ( UIImagePickerControllerSourceType . Camera ) ;
451
451
}
452
452
453
+ public getParentViewController ( ) {
454
+ var responder : UIResponder = this . view ;
455
+ do {
456
+ responder = responder . nextResponder ;
457
+ } while ( responder && ! ( NSStringFromClass ( responder . class ( ) ) === 'UIViewControllerImpl' ) ) ;
458
+
459
+ return < UIViewController > responder ;
460
+ }
461
+
453
462
public chooseFromLibrary ( options ?: IChooseOptions ) : Promise < any > {
454
463
return new Promise ( ( resolve , reject ) => {
455
464
this . _pickerDelegate = null ;
@@ -493,7 +502,7 @@ export class MySwifty extends SwiftyCamViewController {
493
502
494
503
imagePickerController . modalPresentationStyle = UIModalPresentationStyle . CurrentContext ;
495
504
496
- rootVC ( ) . presentViewControllerAnimatedCompletion ( imagePickerController , true , null ) ;
505
+ this . getParentViewController ( ) . presentViewControllerAnimatedCompletion ( imagePickerController , true , null ) ;
497
506
} ) ;
498
507
}
499
508
@@ -733,11 +742,6 @@ export class CameraPlus extends CameraPlusBase {
733
742
}
734
743
}
735
744
736
- const rootVC = function ( ) {
737
- let appWindow = UIApplication . sharedApplication . keyWindow ;
738
- return appWindow . rootViewController ;
739
- } ;
740
-
741
745
const createButton = function (
742
746
target : any ,
743
747
frame : CGRect ,
0 commit comments