Closed StackHelp closed 4 years ago
Is customPlayerBar inherit from LNPopupCustomBarViewController?
To update popupItem from the popupContentViewController: popupItem is accessible from your vc (the popupContentViewController): self.popupItem
To update popupItem from the container VC: containerVC.popupBar.popupItem
@iDevelopper
Yes class PlayerPopUpBarVC: LNPopupCustomBarViewController
class PlayerPopUpBarVC: LNPopupCustomBarViewController {
@IBOutlet weak var songImageView: UIImageView!
@IBOutlet weak var songTitleLabel: UILabel!
}
I don't understand this. In #354 , Leo Suggests this before closing an issue. Custom bars do not have images, progress bars or any other of the standard views. It's up to you to implement them.
.
So, as I want custom things and custom layouts, I made a custom bar but it's not accessible than it's of no use.
These are some logs I got
(lldb) po self.popupBar
<LNPopupBar: 0x7ffa7afa11d0; frame = (0 896; 414 0); clipsToBounds = YES; hidden = YES; gestureRecognizers = <NSArray: 0x60000330aa30>; layer = <CALayer: 0x600003d2df00>>
(lldb) po self.popupBar.customBarViewController
nil
(lldb) po self.popupBar.popupItem
nil
And what about po self.tabBarController.popupBar
@iDevelopper It's nil
as well
From which controller?
@iDevelopper
let vc = PlayerViewController.instantiate()
let customPlayerBar = PlayerPopUpBarVC.instantiate()
self.tabBarController?.popupBar.customBarViewController = customPlayerBar
self.tabBarController?.presentPopupBar(withContentViewController: vc, openPopup: true, animated: true, completion: nil)
I am calling if let customItem = self.tabBarController?.popupBar.customBarViewController as? PlayerPopUpBarVC { }
in PlayerViewController
which is contentViewController
In your playerViewController, which is the contentViewController, you simply access the popuItem like this:
self.popupItem
The popupBar is: self.popupPresentationContainer?.popupBar (you do not have a tabBarController here, this is the popupPresentationContainer's property) The custom bar controller is self.popupPresentationContainer?.popupBar.customBarViewController
@iDevelopper Here is the log for popupPresentationContainer
in playerViewController
(lldb) po self.popupPresentationContainer?.popupBar.customBarViewController
nil
(lldb) po self.popupPresentationContainer?.popupBar
nil
(lldb) po self.popupPresentationContainer
nil
I think you are in the viewDidLoad function, try in viewWillAppear.
@iDevelopper But why? If it's there in popupPresentationContainer
, then whenever we call we should have get it.
popupPresentationContainer is set during the popup bar presentation. You probably load your playerViewController before the presentation...
Do you need to access to popupPresentationContainer in viewDidLoad? Why?
I am loading it as it described in readme self.tabBarController?.presentPopupBar(withContentViewController: vc, openPopup: true, animated: true, completion: nil)
Yes, this is how you present the popup bar. But your vc (the player view controller) is already allocated and his view loaded. Then in viewDidLoad you can't have access to popupPresentationContainer. Search why his view is already loaded. Look at your instantiate() function... And put a breakpoint in viewDidLoad() function, you will see that the view is loaded before the popup bar presentation.
@iDevelopper I don't understand this scenario. can you help me If I am sharing my screen?
You can share your screen but your code is welcome to understand. I ask the question again:
Do you need to access to popupPresentationContainer in viewDidLoad?
@iDevelopper I want it on runtimes, like when song loads or song change
var currentMedia: Media = Media() {
didSet {
if isViewLoaded {
playMediaScenario() // In this function I want to refer customBarViewController
}
}
}
I have checked you have a git repo for Swift
version as well but I don't think it supports custom controller yet.
Can you present the popup bar and set currentMedia in the completion block? A least for the first song...
@iDevelopper ok. Let me try
@iDevelopper Yes SIr, It worked. Now I understood that the thing is PlayerView Loads even before completing presentation of popupBar and that's why it's not even in hierarchy of controllers and that's why it produces nil
. Thanks a lot for your help and giving this issue too much time.
@StackHelp , glad to hear it works!
I have checked you have a git repo for Swift version as well but I don't think it supports custom controller yet.
This framework support custom bars. But a little outdated, I will update with a new version soon. If you want to test?... The main difference with LN is that this framework uses fewer private APIs and animates views (such as image or controls), as the Apple Music application does.
@iDevelopper Yes, I will surely test it once you updated it. I like to do that.
I am trying to use the custom controller as a
popupBar
and for that, I set up code likeNow, the problem is when I'm trying to refer
customBarViewController
, it gives menil
So, What's the correct way to refer
customBarViewController
that we can change/ update elements that are part of it.Device, OS and Xcode Versions
Simulator: iPhone 11, XCode Version 11.2.1, iOS 13 Device: iPhone 7, XCode Version 11.2.1, iOS 13