Reputation: 893
I have 2 buttons within my UITableViewCell. One of them is shown by default, the other only shows when an action is performed once the first one is tapped. For some reason the buttons do not show unless the cell is selected. They used to show but I've obviously changed something and I don't know what. Any idea? Here's the relevant code:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell: EpisodesCell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! EpisodesCell
configureCell(cell, indexPath: indexPath)
return cell
}
func configureCell(cell: EpisodesCell, indexPath: NSIndexPath) {
let data = fetchedResultsController.objectAtIndexPath(indexPath) as! CDEpisode
cell.textLabel!.text = data.title
cell.downloadButton.hidden = false
cell.downloadButton.tag = indexPath.row
cell.downloadButton.addTarget(self, action: "downloadButtonClicked:", forControlEvents: UIControlEvents.TouchUpInside)
if data.isDownloaded == "yes" {
cell.playButton.hidden = false
}
}
class EpisodesCell: UITableViewCell {
@IBOutlet weak var playButton: UIButton!
@IBOutlet weak var downloadButton: UIButton!
@IBAction func downloadEpisode(sender: AnyObject) {
println(sender)
println(sender.superview)
}
}
Link to a screenshot of the cell: https://www.evernote.com/l/ACRiU8RKu9tEr58ULTBzIbk00h688Dt1q-w
Thank you
Upvotes: 1
Views: 1716
Reputation: 934
you should check this : https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/#//apple_ref/occ/instm/UIView/bringSubviewToFront:
the code should be look like this :
self.view.bringSubviewToFront(button2)
Upvotes: 1