Git Product home page Git Product logo

Comments (7)

antoniocasero avatar antoniocasero commented on July 18, 2024 1

It seems you have a retain cycle in your panel. I saw that you are working with Timers, if the timer is not properly invalidated, then it retain the timer target, in this case, your ViewController.
If this is the case, it is not related to Panels, this is a lifecycle issue.
Let me know if my thinking is right :)

from panels.

antoniocasero avatar antoniocasero commented on July 18, 2024

Hi Jordan, just to be sure, when you scroll down/up the panel appear again without any animation, right? The use of Notifications should not be a problem.

We need a bit of debugging. Are you presenting the panel using notifications too? could you check the view hierarchy? could you add a breakpoint in the show method to monitor who is adding a panel?
I will try to reproduce it locally, but I need to know how are you presenting the panel. (I mean, the code above to present the panel is in -viewDidLoad() ?)

from panels.

JordanCoin avatar JordanCoin commented on July 18, 2024

Yes with no animation it appears again. I'm presenting the panel using notifications and when I look at the view hierarchy after dismissing the panel it's removed from the hierarchy. Then a moment later when I scroll it is re-added.

So in my app, the panel will open whenever my database returns a session that's start and end date objects fall between the current date. So at start there's a chance it will run a timer that I pass the session data too.

    @objc func presentPannel(runningTimer: Timer) {
        guard let userInfo = runningTimer.userInfo as? [String: Any], let session = userInfo["Session"] as? Session else { return }
        
        if let currentSessionInterval = userInfo["currentSessionInterval"] as? TimeInterval {
            self.sessionInterval = currentSessionInterval
        } else {
            let sessionTimeInterval = session.endDate.timeIntervalSince(session.startDate)
            self.sessionInterval = sessionTimeInterval
        }
        
        guard let currentSessionName = session.clientName else { return }
        self.sessionClientName = currentSessionName
        self.runningSession = session
        
        let panel = UIStoryboard.instantiatePanel(identifier: "Timer")
        var panelConfiguration = PanelConfiguration(size: .custom(230))
        panelConfiguration.animateEntry = true
        panelConfiguration.useSafeArea = false
        panelConfiguration.respondToDrag = true
        
        self.panelManager.show(panel: panel, config: panelConfiguration)
    }

The other way you can present the panel is by clicking on a cell in the didSelectRow method. It's the same code as above but not in a notification.

Also when I placed breakpoints and a few print statements I noticed after I dismiss it and scroll as it reopens the panelDidCollapse() function is called. I don't know if that will help or not.

Let me know if you think you need some more info, I'm very confused at why it keeps showing after it's dismissed.

from panels.

antoniocasero avatar antoniocasero commented on July 18, 2024

Well, if the view is deleted from the hierarchy, it seems you are re-adding the panel in the code, one of them (put breakpoints in the self.panelManager.show to know who is firing the event). The reason why panelDidCollapse() is called is that the panelManager is listening to the tap events in the superview (so it can be closed tapping outside the view), if this is giving you problems, you could disable it in the configuration.
Let me know your findings.

from panels.

JordanCoin avatar JordanCoin commented on July 18, 2024

So after further investigation, I noticed when I dismissed the panel and before the Panel reappeared it's still in the view hierarchy (Bell.TimerViewController pictured below)

screen shot 2018-12-05 at 10 55 16 am

So even with it dismissed and not visible the ViewController which holds the Panel is still in the hierarchy. Here's a screenshot of the app when I was looking at the Hierarchy (of course if I move the table or go to another view and come back it pops back up as if it was never dismissed).

img_0268

I've put breakpoints in the places I'm showing the panel and it is only called once. Is there a workaround for removing the panel from the subview? Since it conforms to ViewController and Panels It won't let me attempt to do this.

from panels.

JordanCoin avatar JordanCoin commented on July 18, 2024

So that was it! I was holding a retain cycle for many things actually 😅 and ended up having to remove the panelVC's reference - let panelVC = UIStoryboard(name: "Timer", bundle: nil).instantiateViewController(withIdentifier: "TimerViewController") as! TimerViewController
To do that all I did was call self.panelVC.view.removeFromSuperview() while dismissing the panel.

        self.panelManager.dismiss {
            self.isPannelOpen = false
            self.panelDismissed = true
            self.panelVC.view.removeFromSuperview()
            NotificationCenter.default.removeObserver(self)
        }

This did the job and now It's dismissing! Thanks so much for your help!

from panels.

antoniocasero avatar antoniocasero commented on July 18, 2024

Happy to help! ✨

from panels.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.