I have a class of UITableViewCell
called PodcastTableViewCell
that has a button (connected via nib/storyboard) called playButton
.
This play button is also connected to an IBAction (in this super class) that prints to console and changes its button state when touched -
if(!isDownloaded)
{
playButton.setImage(downloadImg , for: UIControlState.normal)
} else {
if(isPlaying)
{
playButton.setImage(pauseImg, for: UIControlState.normal)
} else {
playButton.setImage(playImg, for: UIControlState.normal)
}
}
I have these in a table. When I select a cell, I expand into a detail controller with a subclassed PodcastTableViewCell
like this:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "episodeDetail",
let detailController = segue.destination as? EpisodeDetailController,
let sender = sender as? PodcastTableViewCell {
detailController.episode = sender.episode
Problem is even with this as all of my subclass (even tried overriding the IBAction), the button that IS INTERACTIVE/changes state in table form does not trigger anything when expanded:
class PodcastDetailPlayerCell: PodcastTableViewCell {
override func awakeFromNib() {
super.awakeFromNib()
episodeName.text = ""
}
@IBAction override func playOrDownloadEpidode() {
print("Happened~!")
}
override func layoutSubviews ()
{
print("DOING THIS: episode name \(self.episode?.title)")
self.playButton.isUserInteractionEnabled = true
self.bringSubview(toFront: playButton)
self.updateCell()
super.layoutSubviews()
}
}
What is wrong with this button? Am I missing something?