PanModal icon indicating copy to clipboard operation
PanModal copied to clipboard

Present view controller without animation doesn't work

Open ton252 opened this issue 4 years ago • 4 comments

I've tried to present panviewcontroller without animation in example project and it doesn't work. For example if we change animated: true

present(viewControllerToPresent, animated: true, completion: completion)

to animated: false

present(viewControllerToPresent, animated: false, completion: completion)

it stops working

ton252 avatar Jan 22 '21 14:01 ton252

Hi @ton252! I will look into this early next week. Thank you for reporting!

lauraweaver avatar Jan 22 '21 16:01 lauraweaver

May be It will help you. The problem is in presentationTransitionWillBegin method and in adjustPresentedViewFrame. If for example wrap this method in DispatchQueue.main.async this will fix the bug. Something like this:

override public func presentationTransitionWillBegin() {
        guard let containerView = containerView else { return }
        
        layoutBackgroundView(in: containerView)
        layoutPresentedView(in: containerView)
        configureScrollViewInsets()
        
        guard let coordinator = presentedViewController.transitionCoordinator else {
            backgroundView.dimState = .max
            return
        }
        
        coordinator.animate(alongsideTransition: { [weak self] _ in
            self?.backgroundView.dimState = .max
            self?.presentedViewController.setNeedsStatusBarAppearanceUpdate()
        })
        
        // HotFix
        DispatchQueue.main.asyncAfter(deadline: .now()) { [weak self] in
            self?.adjustPresentedViewFrame()
        }
    }

I think the problem is in layout calculation cycle. Maybe adjustPresentedViewFrame needs to be called again in other places. I hope this will help you to find the bug

ton252 avatar Jan 22 '21 23:01 ton252

I've encountered the same issue. Have you guys already have a solution on this one?

Albert-Jr avatar Feb 18 '21 09:02 Albert-Jr

@ton252 @lauraweaver Has the problem been solved

BeingCode avatar Mar 11 '22 04:03 BeingCode