我在viewDidLoad
这样的一个数组,它包含UIColor
将被用于填充表格视图单元格背景颜色如何用数组中的颜色填充表格视图单元格背景?
self.ColorArray = [NSArray arrayWithObjects:
@"[UIColor redColor];",
@"[UIColor redColor];",
@"[UIColor redColor];", nil];
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
cell.contentView.backgroundColor = [self.ColorArray objectAtIndex: indexPath.row % self.ColorArray.count];
}
但这种崩溃掉给抛出这个错误:
-[__NSCFConstantString CGColor]: unrecognized selector sent to instance 0x137b28 -
检查码与该变形例self.ColorArray = [NSArray的arrayWithObjects: [的UIColor redColor], [的UIColor redColor], [的UIColor redColor],零]。 –