ios - 按下按钮时, button.setImage(nil) 不起作用
问题描述
我正在尝试创建日语填字游戏。将按钮用作单元格。尝试插入系统映像时,它可以工作(案例模式 1)。但是当我选择其他模式(2)时,图标不会消失。
let img1 = UIImage(systemName: "multiply"))
@IBAction func cellClicked(_ sender: UIButton) {
for cell in cellButtons {
if cell.tag == sender.tag {
switch typeCell { //when mode changes
case 1:
cell.setImage(img1, for: .normal) //work
default/*2*/:
cell.setImage(nil, for: .normal) //don't work, but running without errors
}
}
}
}
我试图只使用发件人(没有if cell.tag == sender.tag
; 没有工作),然后创建 IBOutlet 集合并运行上面的代码。
更新:我发现并决定使用 .isHidden。那行得通,我也解决了我的其他问题:) 谢谢!
解决方案
推荐阅读
- css - 正文中断布局上的等宽字体
- java - 使用 Java 和 Python 的 uuencoded 文件之间的区别
- sql-server - 如何根据 json 中的 id 从表中删除行
- php - 使用 PHP SoapClient 将多个值发送到同一个字段
- python - AttributeError:模块“pydotplus”没有属性“节点”
- python - 未定义字符的 Unicode 编码错误
- django - Django - 空表单无法保存在数据库中
- c++ - 使用命名空间的 QT 测试
- java - 是否可以先应用 maven 叠加层,然后开始构建应用了叠加层的项目?
- terraform - 012 升级 - 带模块调用的 cidrsubnet