Open jbafford opened 3 years ago
We are having the same issue! Was working fine on full screen modal presentations, but once switched to presented from non full screen it bugs out. Your suggested fix does work for non full screen presentations parents.
A "fix" for the not-full-screen case is to remove both of those lines, and then it appears to work correctly on both iOS and on Mac Catalyst. However, this is not an adequate fix, because when dismissing to the (otherwise working) full-screen view controller, there's a white flash during the transition that shouldn't be there.
If it's any help here I encapsulate cropViewController
in a UINavigationController
and it seems to do the trick for now.
let nvc = UINavigationController(rootViewController: cropViewController)
present(nvc, animated: true, completion: nil)
Workaround:
let controller = CropViewController(image: image)
controller.transitioningDelegate = nil
controller.modalTransitionStyle = .crossDissolve
sourceController.present(controller, animated: true)
Describe the bug I have a presented view controller that is not full-screen that itself presents
TOCropViewController
. In this configuration, when theTOCropViewController
is dismissed, the parent view controller's view is removed, leaving a transparent hole.Another part of my app has a presented full-screen view controller that also presents a
TOCropViewController
, which works correctly.I've tracked this down to
-[TOCropViewControllerTransitioning animateTransition:]
. Specifically, I see two problems:if self.isDismissing
sets thepreviousController.view.frame = containerView.bounds
. This does not appear to be correct in the not-full-screen parent case. With a not-full-screen parent, the parent view's size is set to the wrong size, because the assumption that the previous controller's view frame is the same size as thetransitionContext.containerView
is not correct. As a result, the view is changed to be larger than its container, and so content winds up incorrectly positioned. This is obvious on Mac Catalyst, and it seems to me that this would not be correct on iOS as well (but possibly harder to see because of the smaller size difference), but I have not done any investigation to prove or disprove that.[containerView insertSubview:previousController.view belowSubview:cropViewController.view];
: When dismissing, the previous controller's view is moved into the transition container view, but this seems to mean that the view is removed from the previous controller. Thus, when the transition completes, thepreviousController
has its view removed, and becomes a transparent hole.A "fix" for the not-full-screen case is to remove both of those lines, and then it appears to work correctly on both iOS and on Mac Catalyst. However, this is not an adequate fix, because when dismissing to the (otherwise working) full-screen view controller, there's a white flash during the transition that shouldn't be there.
Another "fix" is to remove creating and setting the
_transitionController
in theTOCropViewController
init. In my testing, it appears to work correctly (for both full-screen and not-full-screen presenting VCs), which makes me wonder if the transition controller is even needed in the case that the delegate implements the didFinish/didCrop methods.iOS Device: