I'm doing a segue back to the root view controller using:
_ = self.navigationController?.popToRootViewController(animated: true)
and the Swift Message does appear, but it just never goes away even if I have it with a specific duration. Any help with this?
My guess is you're using presentationContext = .viewController(...) configuration? If you're in a navigation controller, SwiftMessages doesn't handle this ideally cases where you want the message to automatically go away when you pop the view controller. This is because the message view is added to the navigation controller's view hierarchy instead of the view controller's. I originally built it this way to help with proper positioning of views under navigation bars and to avoid issues with scroll views.
Can you try this and let me know if it works?
presentationContext = .view(...) configuration to embed the message view in your view controller's view hierarchy instead of the navigation controller.viewDidDisappearActually, I'm using config.presentationContext = .window(windowLevel: UIWindowLevelStatusBar) throughout the whole app, so I'm not sure if #1 would help.
viewWillDisappear instead, viewDidDisappear didn't do anything. Also, it did so instantly, I still need the message to appear for a little bit. Almost there!A workaround I used is adding a delay. So I make the message appear, and segue after a few seconds which works for now, but I'd still like to segue and message at the same time.
I'll look into it when I get a chance.
@miserylee Could you take the attached project, modify it to reproduce your issue, and reattach it? I haven't been able to reproduce it so far.
@wtmoose I found that use a local instance init in view controller, only which can produce the issue.
Sometimes we want to hide the local instance after view controller did disappeared, the local instance is alive, but the intermediate weak current in hide function is revoked when asyncAfter closure been called.
So why we want to use local instance? Different instance should be maintained separately.
I have discussed the commit with my workmate, it's ok to avoid memory leak without intermediate weak current
@OsmarMtz it seems like this should be fixed in the last commit. Reopen if you find out that it isn't fixed.
Most helpful comment
My guess is you're using
presentationContext = .viewController(...)configuration? If you're in a navigation controller, SwiftMessages doesn't handle this ideally cases where you want the message to automatically go away when you pop the view controller. This is because the message view is added to the navigation controller's view hierarchy instead of the view controller's. I originally built it this way to help with proper positioning of views under navigation bars and to avoid issues with scroll views.Can you try this and let me know if it works?
presentationContext = .view(...)configuration to embed the message view in your view controller's view hierarchy instead of the navigation controller.viewDidDisappear