TimOliver / TOCropViewController

A view controller for iOS that allows users to crop portions of UIImage objects
http://www.timoliver.com.au/2015/06/21/tocropviewcontroller-an-open-source-image-cropper-for-ios/
MIT License
4.68k stars 932 forks source link

Dismissing a TOCropViewController presented from a not-full-screen VC causes the presenting VC's view to be removed #486

Open jbafford opened 3 years ago

jbafford commented 3 years ago

Describe the bug I have a presented view controller that is not full-screen that itself presents TOCropViewController. In this configuration, when the TOCropViewController 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:

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 the TOCropViewController 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:

mikemike396 commented 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.

ggueno commented 3 years ago

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)
ky1vstar commented 3 years ago

Workaround:

let controller = CropViewController(image: image)
controller.transitioningDelegate = nil
controller.modalTransitionStyle = .crossDissolve
sourceController.present(controller, animated: true)