Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Swift-UIImage不显示在TableViewCell中(单击时显示,单击其他单元格时消失)_Ios_Swift_Uitableview_Uiimage - Fatal编程技术网

Ios Swift-UIImage不显示在TableViewCell中(单击时显示,单击其他单元格时消失)

Ios Swift-UIImage不显示在TableViewCell中(单击时显示,单击其他单元格时消失),ios,swift,uitableview,uiimage,Ios,Swift,Uitableview,Uiimage,我用自定义单元格创建了一个tableview 情节提要如下所示: 如您所见,我在单元格的右侧放置了复选符号。 我指定了自定义单元格类,如下所示: class CustomCell: UITableViewCell{ @IBOutlet weak var checkImage: UIIMageView! } 在tableview类中,我的函数声明: override func tableView(_ tableView: UITableView, cellForRowAt indexP

我用自定义单元格创建了一个tableview

情节提要如下所示:

如您所见,我在单元格的右侧放置了复选符号。 我指定了自定义单元格类,如下所示:

class CustomCell: UITableViewCell{
    @IBOutlet weak var checkImage: UIIMageView!
}
在tableview类中,我的函数声明:

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "customCell", for: indexPath) as! CustomCell

    // Configure the cell...
    cell.textLabel?.text = people[indexPath.row]
    return cell
}
奇怪的是。。。单击单元格时,将显示复选标记。当单击其他单元格时,复选标记将消失,并且仅显示在选定的单元格中。 我真的不知道这里发生了什么。。 我试着回答类似的问题,但没有一个有效。 任何帮助都将不胜感激。谢谢


只需为tableview选择
乘法选择

我相信您想要的是能够选择多个单元格

tableView.allowsMultipleSelection = true
添加上面的行应该可以解决您的问题。 但是,为什么不使用附件复选标记?您甚至可以使用基本UITableViewCell并选择acc
您只需设置
cell.accessoryType=.checkmark
cell.accessoryType=.none

显示您的
didSelectRowAt
方法。另外,您知道可以对内置复选标记执行
cell.accessoryType=.checkmark
?哇。。。让我试试我过去的两个小时。。非常感谢。你解决了我需要的问题。但是,嗯,为什么它不起作用呢?没问题!很高兴能帮上忙:)还有更多的事情要实现,我想做的不是选择倍数。。是的,我本可以用这个配件,但我只是在5分钟前才知道它的存在