Tocropviewcontroller: Dismissing transition (iOS 13) problems

Created on 8 Aug 2019  ·  23Comments  ·  Source: TimOliver/TOCropViewController

I've encounter an issue when presenting the crop controller over a Navigation controller.

When dismissing the crop controller, at the end of the transition the navigation controller view is being removed and not displayed... (happens in iPhone and iPad and only on iOS 13).

not to mention that the navigation is still there and the UI is "stuck".

bug

Most helpful comment

 func cropViewController(_ cropViewController: CropViewController, didFinishCancelled cancelled: Bool) {
        //This code fails on iOS13.
        //cropViewController.dismiss(animated: true)

        let viewController = cropViewController.children.first!
        viewController.modalTransitionStyle = .coverVertical
        viewController.presentingViewController?.dismiss(animated: true, completion: nil)
    }

This method works well on iOS 13.
I don't know why.

I expect you to find a better way.

https://www.dropbox.com/s/wyzc8errinfap1f/TestCrop.zip?dl=0

All 23 comments

@uchiaTziki Um. You might have to show me, sorry! Can you attach a screenshot?

attached screenshots...

  1. presenting modal with image picker.
  2. picked image
  3. present crop controller from that cell
  4. after cancelling, the dismissing cause the image picker to vanish (and you're seeing the initial presenting controller - I coloured the controller in white)

Hope that makes things clearer..
1
2
3
4

Hmm, so you're presenting it inside another view controller getting presented?

I wonder if this dismiss code is ending up dismissing the wrong view controller then:

https://github.com/TimOliver/TOCropViewController/blob/8770be8407540f5873fe714870771cea8a382ac7/Objective-C/TOCropViewController/TOCropViewController.m#L895

Can you please try changing the code in there and seeing if you can find a combination that fixes it?

Without being able to test it myself, there's nothing I can do from my end. Sorry!

I tried almost anything, but I will try again..
The controller in the back is not being dismissed.. it's view is being removed (which is weird).

Did you try these code before presenting cropViewController?

if #available(iOS 13.0, *) {
 cropViewController.modalPresentationStyle = .fullScreen
}

Tried it this morning. It does solve the bug but the animation is the default modal animation (from bottom to top).
The special animation from view/frame doesn't work with this solution

@uchiaTziki did you found any fix ?

Is this reproducible in the sample app at all? If so, I can potentially have a look at it.

The way modal presentations work in iOS 13 changed from previous versions of iOS. But I haven't had a good chance to work out exactly what we need to do to update the code for that yet.

As far as I can see, it's not working properly when you have the following:

  • Navigation Controller (A) pushes a View Controller (B)
  • View Controller (B) presents View Controller (C) as form sheet
  • View Controller (C) presents CropViewController
  • Tap Cancel or Done on CropViewController and you'll can spot the bug.

Sorry I was on vacation.

Did you try these code before presenting cropViewController?

if #available(iOS 13.0, *) {
 cropViewController.modalPresentationStyle = .fullScreen
}

Using that (@TimOliver ) in the latest Xcode beta did the trick. So the transition animation is working for me now.

This worked for me as well.

 func cropViewController(_ cropViewController: CropViewController, didFinishCancelled cancelled: Bool) {
        //This code fails on iOS13.
        //cropViewController.dismiss(animated: true)

        let viewController = cropViewController.children.first!
        viewController.modalTransitionStyle = .coverVertical
        viewController.presentingViewController?.dismiss(animated: true, completion: nil)
    }

This method works well on iOS 13.
I don't know why.

I expect you to find a better way.

https://www.dropbox.com/s/wyzc8errinfap1f/TestCrop.zip?dl=0

Hi, I meet the bug on iOS 13.1

if I use
dismiss(animated: true, completion: nil)
on iOS 13.1,

All ViewController disappear.

crop

I don't know why.

I just had to set cropViewController.modalTransitionStyle = .coverVertical as a workaround since it then does not use the custom transition anymore...

Same thing as @oblq here.

Did you try these code before presenting cropViewController?

if #available(iOS 13.0, *) {
 cropViewController.modalPresentationStyle = .fullScreen
}

Fixed my issue, thank you

if #available(iOS 13.0, *) {
cropViewController.modalPresentationStyle = .fullScreen
}

Thanks. This fixed my issue on iOS 13

after crop image , dismissing the crop controller, at the end of the transition the navigation controller view is being removed and not displayed

please help me out

after crop image , dismissing the crop controller, at the end of the transition the navigation controller view is being removed and not displayed

please help me out

Hi! Just set cropViewController.dismiss(animated: **false**, completion: nil) instead of cropViewController.dismiss(animated: **true**, completion: nil)

I've been trying to solve this problem too. As @ibdman1991 says, disabling the animation works but it just looks bad. I think removing the transitioningDelegate could be a nicer solution, not sure how impactful this would be though.

    let cropViewController = CropViewController(image: image)
    cropViewController.modalTransitionStyle = .crossDissolve
    cropViewController.transitioningDelegate = nil

if #available(iOS 13.0, *) {
cropViewController.modalPresentationStyle = .fullScreen
}

This issue is solved in iOS 13 and above Thanks

if #available(iOS 13.0, *) {
cropViewController.modalPresentationStyle = .fullScreen
// cropViewController.modalTransitionStyle = .crossDissolve
cropViewController.transitioningDelegate = nil
}
Working for me

Uhh. Okay. Since explicitly setting the presentation style to full screen seemed to fix it for the majority of people, I'm closing this off. :)

If you have a specific use-case that requires an explicitly different modal presentation style, please open a new issue and explain very carefully what you're trying to do. Please bear in mind, if it's a bug in iOS 13, there might not be a lot we can do here.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings