【发布时间】:2018-09-13 17:44:56
【问题描述】:
我在 CellForRowat Indexpath 中使用 For 循环来更改颜色,但它显示错误,我该如何解决它。我输入了正确的键值
错误(由于未捕获的异常而终止应用程序 'NSInvalidArgumentException',原因:'-[_SwiftValue objectForKey:]: 无法识别的选择器发送到实例 0x6040000f6680'
for all in arrayForType!
{
let type = (all as AnyObject).object(forKey: "type") as! String
print(type)
if type == "Send"
{
cell.lblForSend.backgroundColor = UIColor.red
}
else
{
cell.lblForSend.backgroundColor = UIColor.green
}
}
【问题讨论】:
-
哪里出错了
-
可以在tableView(_tableView: UITableView, cellForRowAt indexPath: IndexPath)方法中设置。在这个方法里面可以设置条件,可以设置背景颜色。
-
你确定问题出在那个for循环上吗?
标签: ios swift uitableview uilabel