PanModal icon indicating copy to clipboard operation
PanModal copied to clipboard

Not working with iOS 17.1+

Open Arrankar opened this issue 2 years ago • 18 comments

Description

Describe your issue here.

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

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

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

  • [x] I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • [x] I've read and agree to the Code of Conduct.
  • [x] 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

Arrankar avatar Oct 30 '23 21:10 Arrankar

What should we do?

Noah-JJ avatar Oct 31 '23 01:10 Noah-JJ

What should we do?

Start to search new library I guess

Arrankar avatar Oct 31 '23 10:10 Arrankar

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 😃

yavl avatar Oct 31 '23 12:10 yavl

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.

PhanithNY avatar Oct 31 '23 13:10 PhanithNY

Same issue here. The interesting part is that if click on the hierarchy button I see the controller I am trying to present. It is part of the hierarchy.

Pato-Salazar avatar Nov 01 '23 20:11 Pato-Salazar

遇到了同样的问题

hewang1016729378 avatar Nov 02 '23 02:11 hewang1016729378

Can confirm, that workaround provided by @yavl works. Moving all layout configuration from constructor to viewDidLoad (or other lifecycle methods) fixes the issue.

Ashok28 avatar Nov 02 '23 12:11 Ashok28

Does not work for me. Maybe because I have a collectionView in the modal that is being presented??.. Is this library abandoned?...

Pato-Salazar avatar Nov 02 '23 15:11 Pato-Salazar

Does not work for me. Maybe because I have a collectionView in the modal that is being presented??.. Is this library abandoned?...

if you are presenting UICollectionViewController, try making minimal reproducible example with UIViewController + UICollectionView on it instead and see if that helps.

yavl avatar Nov 02 '23 15:11 yavl

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

oscarcv avatar Nov 03 '23 13:11 oscarcv

@oscarcv this actually works for me as well. Nicely done. Are you cool if I create a PR with your solution?

Pato-Salazar avatar Nov 03 '23 14:11 Pato-Salazar

@Pato-Salazar

https://github.com/slackhq/PanModal/pull/204

oscarcv avatar Nov 03 '23 16:11 oscarcv

@oscarcv I tagged the library owners.. if we get lucky they might merge this...thanks again

Pato-Salazar avatar Nov 03 '23 17:11 Pato-Salazar

Got same issue, on iOS 17.1.1, 14 pro max

In our case it showing up for first time and after that only dark screen, if we try to open modal multiple times

abmomen avatar Nov 16 '23 05:11 abmomen

for iPad it has an issue with your fix @oscarcv, any idea?

springfk avatar Dec 13 '23 07:12 springfk

for iPad it has an issue with your fix @oscarcv, any idea?

@springfk If you provide me with a test app to reproduce the problem, I try to review it.

oscarcv avatar Dec 13 '23 14:12 oscarcv

fix problem with iOS 17.1 /// action

lazy var workingVC = WorkingTimeViewController() let navigationController = navigationVC()| navigationController.setViewControllers([workingVC], animated: false)

/// need create class type UINavigationController class navigationVC: UINavigationController, PanModalPresentable { var panscrollable: UIScollView? }

Van-Lucky avatar Dec 16 '23 01:12 Van-Lucky

Faced the same issue but with using PanModal for UIPageViewController. Created a PR here, tested on iPhone and iPad. Please test on your side if you can. Thanks

ppave avatar Jan 15 '24 12:01 ppave