scenee / FloatingPanel

A clean and easy-to-use floating panel UI component for iOS
MIT License
5.61k stars 510 forks source link

Dismiss action does not remove contentViewController? #612

Closed grumpy-sw closed 1 year ago

grumpy-sw commented 1 year ago

Description

Hi. I want to completely remove the FloatingPanelController's contentViewController when closing the panel using the existing implemented behavior. For example, when closing the panel through a customized button and setting the parent ViewController as a delegate, I could explicitly call the following code to remove the contentViewController:

fpc.set(contentViewController: nil)

or

fpc.contentViewController = nil

However, When closing the panel via implemented behavior(like dismissalTapGestureRecognizer), the panel simply disappears from the screen, and the contentViewController does not remove. It can be observed through Xcode's Memory Graph.

스크린샷 2023-10-26 16 09 14

In my expectation, the BottomSheetViewController should be deallocated from memory.

Of course, to make it behave as I want, I can call the delegate method in viewDidDisappear. However, I'd like to know whether this is intentional, and whether explicitly setting contentViewController to nil, as in the above code, is considered an incorrect approach.

Thanks.

Environment

version: 2.8.0 Swift Package Manager iOS 15.0 Xcode version: 15.0

scenee commented 1 year ago

Hi,

Dismiss action doesn't deallocate an instance of FloatingPanelController object. It just hides the pane and removes the instance from the parent view controller. That's why you have to deallocate the instance. If you release it, if the content view controller has no references from other objects, the content view controller will be deallocated too.

The reason why the above design is because it's easy to reuse an instance of FloatingPanelController object and its content view controller.

grumpy-sw commented 1 year ago

I understand it. Thanks a lot!