gpt4 book ai didi

ios - 按钮未注册水龙头

转载 作者:行者123 更新时间:2023-11-28 07:00:33 25 4
gpt4 key购买 nike

此单元格中的按钮不记录点击。 downloadEpisode() 中的打印语句不打印,点击时按钮不突出显示/改变颜色。然而,当我点击按钮时,表格 View 单元格被选中。我以为单元格在按钮 View 下方,但事实并非如此(我已经检查了 UI View 层次结构)。

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject?) -> PFTableViewCell? {
let cell: PFTableViewCell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! PFTableViewCell
if let title = object?["title"] as? String {
cell.textLabel?.text = title
}
let downloadButton = UIButton(type: .RoundedRect)
downloadButton.frame = CGRectMake(cell.contentView.bounds.width - 100, cell.contentView.bounds.height / 2, 100, 0)
downloadButton.setTitle("Download", forState: .Normal)
downloadButton.setTitleColor(UIColor.blueColor(), forState: .Normal)
downloadButton.setTitleColor(UIColor.redColor(), forState: .Selected)
downloadButton.tag = indexPath.row
downloadButton.addTarget(self, action: "downloadEpisode:", forControlEvents: .TouchUpInside)
cell.contentView.addSubview(downloadButton)
cell.contentView.bringSubviewToFront(downloadButton)
// using cell.addSubview(downloadButton) doesn't work either.


return cell
}

最佳答案

不确定这是否对其他人有帮助,但这是解决方案:

    downloadButton.frame = CGRectMake(cell.contentView.bounds.width - 100, cell.contentView.bounds.height / 2, 100, 0)

应该是

     downloadButton.frame = CGRectMake(cell.contentView.bounds.width - 100, cell.contentView.bounds.height / 2, 100, 40)

按钮的高度为 0,这是故意的,因为文本仍会正常显示,我认为触摸区域只是文本,但事实并非如此。

关于ios - 按钮未注册水龙头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32154615/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com