PanModal: Not working with iOS 17.1+

Description

Describe your issue here.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I’ve read and understood the Contributing guidelines and have done my best effort to follow them.
  • I’ve read and agree to the Code of Conduct.
  • I’ve searched for any related issues and avoided creating a duplicate issue.

Bug Report

Modal controller don’t present on iOS 17.1 and upper.

Reproducible in:

PanModal version: 1.2.7

iOS version: 17.2 beta

Steps to reproduce:

  1. Create controller for present by PanModal
  2. Present that controller by “presentPanModal” func
  3. Look at dark screen without your controller.

Expected result:

Modal controller under dark screen.

Actual result:

Dark screen without modal controller.

Attachments:

Снимок экрана 2023-10-31 в 00 18 58

About this issue

  • Original URL
  • State: open
  • Created 8 months ago
  • Comments: 18

Commits related to this issue

Most upvoted comments

From the tests I have performed the problem appears in the addRoundedCorners function of the PanModalPresentationController class.

 func addRoundedCorners(to view: UIView) {
        let radius = presentable?.cornerRadius ?? 0
        let path = UIBezierPath(roundedRect: view.bounds, // Bounds value is .zero
                                byRoundingCorners: [.topLeft, .topRight],
                                cornerRadii: CGSize(width: radius, height: radius))

        // Draw around the drag indicator view, if displayed
        if presentable?.showDragIndicator == true {
            let indicatorLeftEdgeXPos = view.bounds.width/2.0 - Constants.dragIndicatorSize.width/2.0
            drawAroundDragIndicator(currentPath: path, indicatorLeftEdgeXPos: indicatorLeftEdgeXPos)
        }

        // Set path as a mask to display optional drag indicator view & rounded corners
        let mask = CAShapeLayer()
        mask.path = path.cgPath
        view.layer.mask = mask

        //Improve performance by rasterizing the layer
        view.layer.shouldRasterize = true
        view.layer.rasterizationScale = UIScreen.main.scale
    }

Because when creating the panContainerView object, containerView is nil

    private lazy var panContainerView: PanContainerView = {
        let frame = containerView?.frame ?? .zero // ContainerView is nill
        return PanContainerView(presentedView: presentedViewController.view, frame: frame)
    }()

To solve the problem, we add in line 179, to the frame calculation if it is zero


    override public func presentationTransitionWillBegin() {

        guard let containerView = containerView
            else { return }
        // Fix bug issue
        if self.panContainerView.frame == .zero {
            self.adjustPresentedViewFrame()
        }
    ...

I hope it will be of help

If you embedded viewController inside UINavigationController, try below code:

    let modalVC = SheetViewController()
    let navigationController = UINavigationController()
    //    This isn't work
    //    let navigationController = UINavigationController(rootViewController: modalVC)
    navigationController.setViewControllers([modalVC], animated: false)
    presentPanModal(navigationController)

Hope this help.

Yeah, I can also reproduce this on iOS 17.1. The strange thing was that some ViewControllers were showing up and some were not. Then I realized that the view controller won’t show up on presentPanModal if you add subviews / set up auto layout constraints in init(), so in my particular case the fix was just to move addSubview, snp.makeConstraints code to override func viewDidLoad().

No need to search new library 😃