Skip to content

Commit 4ac0774

Browse files
Merge pull request #8 from PSPDFKit/julian/dismiss
Add dismiss method to iOS module
2 parents f342291 + 9968b2c commit 4ac0774

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

ios/RCTPSPDFKit/RCTPSPDFKitManager.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ @implementation RCTPSPDFKitManager
3535
[presentingViewController presentViewController:navigationController animated:YES completion:nil];
3636
}
3737

38+
RCT_EXPORT_METHOD(dismiss) {
39+
UIViewController *presentedViewController = RCTPresentedViewController();
40+
NSAssert([presentedViewController isKindOfClass:UINavigationController.class], @"Presented view controller needs to be a UINavigationController");
41+
UINavigationController *navigationController = (UINavigationController *)presentedViewController;
42+
NSAssert(navigationController.viewControllers.count == 1 && [navigationController.viewControllers.firstObject isKindOfClass:PSPDFViewController.class], @"Presented view controller needs to contain a PSPDFViewController");
43+
[navigationController dismissViewControllerAnimated:true completion:nil];
44+
}
45+
3846
- (dispatch_queue_t)methodQueue {
3947
return dispatch_get_main_queue();
4048
}

0 commit comments

Comments
 (0)