Comments (7)
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.
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.
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.
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.
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)
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).
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.
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.
Happy to help! ✨
from panels.
Related Issues (20)
- Specify a platform for this target in Example Podfile
- Panels Programmatically HOT 8
- 2nd time dismiss animation works but panel stay HOT 4
- 'NSInvalidArgumentException
- need some help HOT 3
- UITextField will cause the panel to collapse HOT 1
- curveTopCorners() wont work HOT 2
- Support Swift Package Manager HOT 1
- How to apply "modalPresentationStyle = .popover"? HOT 2
- crash when running on real device HOT 2
- keyboard present and Penel moves up with the keyboard
- CocoaPods version is not match the latest version
- support orienation change HOT 2
- content height of collectionview inside panel wrong when orientation change
- Example app crashes if you tap "Close" twice HOT 2
- Show the Panels on top of a TabBar HOT 2
- Does it support below iOS 10? HOT 1
- HeaderHeight calculation pushes Header further down with each show HOT 7
- Drag gesture doesn't follow the movement HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from panels.