From 438f21623d4d905cf92fb16f33089bb84071a71a Mon Sep 17 00:00:00 2001 From: Aizat Akronym Date: Tue, 10 Nov 2020 23:41:46 +0800 Subject: [PATCH] Dismiss or pop view controllers accordingly --- .../TOCropViewController/TOCropViewController.m | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Objective-C/TOCropViewController/TOCropViewController.m b/Objective-C/TOCropViewController/TOCropViewController.m index a16d10b6..fbfa570f 100755 --- a/Objective-C/TOCropViewController/TOCropViewController.m +++ b/Objective-C/TOCropViewController/TOCropViewController.m @@ -887,11 +887,10 @@ - (void)dismissCropViewController // If neither callbacks were implemented, perform a default dismissing animation if (!isDelegateOrCallbackHandled) { - if (self.navigationController) { + if (self.navigationController && self.navigationController.viewControllers.count > 1) { [self.navigationController popViewControllerAnimated:YES]; } else { - self.modalTransitionStyle = UIModalTransitionStyleCoverVertical; [self.presentingViewController dismissViewControllerAnimated:YES completion:nil]; } } @@ -939,8 +938,13 @@ - (void)doneButtonTapped } if (!isCallbackOrDelegateHandled) { - [self.presentingViewController dismissViewControllerAnimated:YES completion:nil]; - blockController.completionWithItemsHandler = nil; + if (self.navigationController != nil && self.navigationController.viewControllers.count > 1) { + [self.navigationController popViewControllerAnimated:YES]; + } + else { + [self.presentingViewController dismissViewControllerAnimated:YES completion:nil]; + blockController.completionWithItemsHandler = nil; + } } };