我的UITableViewCell中有2个按钮。默认情况下会显示其中一个,另一个仅显示在点击第一个操作后执行操作的时间。由于某种原因,除非选择了单元格,否则按钮不会显示。他们曾经表现出但我显然已经改变了一些东西,我不知道是什么。任何的想法?这是相关的代码:
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)
}
}
链接到单元格的屏幕截图:https://www.evernote.com/l/ACRiU8RKu9tEr58ULTBzIbk00h688Dt1q-w
谢谢
答案 0 :(得分:1)
代码应如下所示:
self.view.bringSubviewToFront(button2)