Swift - How to Call and Show XIB/StoryBoard inside from XIB?

Hi!

I got confused while I am trying to achieve showing a xib or storyboard view inside of a xib view.

I have a table filled with ViewCell xibs and every one of them has buttons for playing podcasts.

When the user clicks the "play button", I want to show a full-screen player view top of the screen, like an alert notification with a close button, play button, volume slider, etc.

If I create and show the player view inside of the cell xib, it only shows up to the size of a cell. I want to show the player view full-screen.

Thus, I created another xib file and put the play button, volume slider, etc. in that file.

But I can't call or show the player view xib from the table cell xib.

How can I achieve this? How do I reach another xib file inside of a xib file?

I tried this :
Code Block swift
let podcastViewCell = (UINib(nibName: "PodcastViewCell", bundle: nil), forCellWithReuseIdentifier: "PodcastViewCell")

But couldn't get any value from this for now.

Also, do you suggest using a storyboard view for showing it in xib? If so, I could use storyboard view too but I still need help calling it.
Answered by oguzhanvarsak in 675788022
I have found the answer by using delegates. Now I can hide/unhide (edit, overall) the view's properties. This was the problem answered by Sh_Khan:

Problem is here

Code Block
DetailViewController().setupPodcastPlayer(link: url)

This DetailViewController() is a new instance not the presented one , hook the real shown one and change it's attribute as needed through delegate or a notification if you need to
I have declared a delegate in PodcastViewCell:
Code Block swift
var delegate: PodcastViewCellDelegate?


and its protocol for passing data :
Code Block swift
protocol PodcastViewCellDelegate {
    func podcastButtonClicked(podcastUrl: String)
}


In the View Controller, I want to edit element from, added this :
Code Block swift
extension DetailViewController: PodcastViewCellDelegate {
    func podcastButtonClicked(podcastUrl: String) {
        setupPodcastPlayer(link: podcastUrl)
        podcastPlayerView.isHidden = false
    }
}


Now my player works as expected and I can hide/unhide my UIView!

Thank you for all of your efforts again! Hope to see you in another thread 😅
I see nowhere in the code you posted, before the last message where you described the solution

Code Block
DetailViewController().setupPodcastPlayer(link: url)

nor a call to DetailViewController()

How do you want someone to guess the problem is in a code you don't show.

I regret you made some of us waste their time.

Hope to see you in another thread

Yes, but take care next time please.

Have a good day.
Swift - How to Call and Show XIB/StoryBoard inside from XIB?
 
 
Q