0

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?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
blue
  • 7,175
  • 16
  • 81
  • 179
  • are you sure the button is in the `contentView`? – Sulthan Jun 02 '18 at 19:01
  • your override method won't even compile `@IBAction override func playOrDownloadEpidode()` – Shehata Gamal Jun 02 '18 at 19:08
  • Do you have a gestureRecognizer in the view that could be taking the touches? If so you could try changing the "cancels touches in view" setting. – crperez Jun 02 '18 at 19:31
  • @gamephase How do I do that? Where is that? – blue Jun 02 '18 at 23:31
  • @skyguy check list of objects in your controller, on the left side panel of the Interface Builder. Check if a gesture recognizer is in the list, and you can click on it and change settings on the right side panel. – crperez Jun 03 '18 at 23:12

0 Answers0