我的应用程序有一个带有自定义单元格的TableView。 我想指定使用Parse.com
我希望我的单元格根据名为...的数据类型有一个图像,例如:
如果查询包含等待完成的数据,则单元格必须具有图片“红色图像”
,否则
如果查询包含已完成的数据,则单元格必须具有“绿色图像”。
我怎么办?如果解释困难但我想要的结果是应用程序的用户可以确定要完成哪些数据以及哪些数据不是通过显示表视图而道歉。答案 0 :(得分:1)
在您的Parse.com课程中,添加一个dataCompleted
列bool
。
在cellForRowAtIndexPath
(UITableView
)或cellForItemAtIndexPath
(UICollectionView
)中处理查询结果时,请检查dataCompleted
密钥的bool值,相应地设置图像。
// _dataSource is an array of PFObjects from the Parse.com query
PFObject *rowObject = [_dataSource objectAtIndex:indexPath.row];
if([[rowObject objectForKey:@"dataCompleted"] boolValue])
{
// Data is completed
cell.outletDataCompletedImageView.image = [UIImage imageNamed:@"icon_dataiscompleted"];
}
else
{
// Data still to be completed
cell.outletDataCompletedImageView.image = [UIImage imageNamed:@"icon_datastilltobecompleted"];
}