hyperoslo/Lightbox

Not working in iOS 13. App getting Freeze.

darshit261991 opened this issue ยท 9 comments

Application getting freeze in iOS 13. Not able to open gallery of images.

Same here. I don't think the app is getting frozen. I actually believe the lightbox controller is for some reason invisible.

@darshit261991, this is actually a duplicate of #229

Works as above for .fullScreen, but would love for it to work for .pageSheet/automatic as well in order to get consistency across the UI. Any update on this? Thanks a lot!

I think pod should be reworked. Right now faster approach to work with this lib is removing custom transition.
lazy var transitionManager: LightboxTransition = LightboxTransition()
After removing it you can present easily controller without freezing app after it dismiss.

Works as above for .fullScreen, but would love for it to work for .pageSheet/automatic as well in order to get consistency across the UI. Any update on this? Thanks a lot!

thanks a lot. saved my day

I managed to get it working by using .fullscreen and disabling the transitionManager by inheriting from LightboxController and adding the following code:

    override public func viewDidLoad() {
        super.viewDidLoad()
        
        // Unset transitioning as this causes freezes
        // most probably related to automatic modals in iOS 13
        self.transitioningDelegate = nil
    }

After pulling my hair out over this for a day was able to locate a workaround within the delegate:

Replace guard let fromView = transitionContext.view(forKey: UITransitionContextViewKey.from), let toView = transitionContext.view(forKey: UITransitionContextViewKey.to)

with the following guard let fromView = transitionContext.viewController(forKey: .from)?.view, let toView = transitionContext.viewController(forKey: .to)?.view

in LightboxTransition.swift. There's an open radar for this bug introduced in iOS 13 where custom animated transitioning delegates are failing to deliver target from/to views on anything other than .fullscreen for modals http://www.openradar.me/radar?id=4999313432248320

I won't open a PR for this as its a workaround and not recommended by documentation, but it worked for my purposes today more so than getting rid of the delegate altogether. This way you can preserve the nifty interactive dismiss.

@ReticentJohn 's answer almost worked for me, but when presented over a .pageSheet/.automatic modal, it was removing the view beneath when dismissed. It did get me wondering though, what if the nil from or to views just shouldn't be added to the transition container? (Versus guarding that both must be present.) I tried that and the following changes to that delegate seem to work in both cases for me:

  func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
    let container = transitionContext.containerView

    let fromView = transitionContext.view(forKey: UITransitionContextViewKey.from)
    let toView = transitionContext.view(forKey: UITransitionContextViewKey.to)

    let firstView = dismissing ? toView : fromView
    let secondView = dismissing ? fromView : toView

    if !dismissing { transition(false) }

    if let firstView = firstView {
        container.addSubview(firstView)
    }

    if let secondView = secondView {
        container.addSubview(secondView)
    }

    toView?.frame = container.bounds
    ...

Thank you guys - your comments saved me some hours :)