I tried using your code as below (there is extra code because of debugging attempts:
NSArray *colors = [NSArray arrayWithObjects:@"White",@"Black", @"Dark Grey", @"Light Grey", @"Gray", @"Red", @"Green", @"Blue", @"Cyan", @"Yellow",
@"Magenta", @"Orange", @"Purple", @"Brown",nil];
SCPropertyDefinition *colorPropertyDef = [shoeClassDef propertyDefinitionWithName:@"colorIndex"];
colorPropertyDef.type = SCPropertyTypeSelection;
colorPropertyDef.attributes = [SCSelectionAttributes attributesWithItems:colors allowMultipleSelection:NO allowNoSelection:YES];
colorPropertyDef.title = @"Color";
NSMutableArray *colorImageArray = [[NSMutableArray alloc] initWithCapacity:[colors count]];
float sizeOfImage = 44.0f;
for( NSString *thisColor in colors)
{
UIImage *colorImage = [[UIImage alloc] init];
if( [thisColor isEqualToString:@"White"]){
colorImage = [ImageManipulator imageWithColor:[UIColor whiteColor] sizeX:sizeOfImage sizeY:sizeOfImage];
}else if( thisColor == @"Black"){
colorImage = [ImageManipulator imageWithColor:[UIColor blackColor] sizeX:sizeOfImage sizeY:sizeOfImage];
}else if( thisColor == @"Dark Grey"){
colorImage = [ImageManipulator imageWithColor:[UIColor darkGrayColor] sizeX:sizeOfImage sizeY:sizeOfImage];
}else if( thisColor == @"Light Gray"){
colorImage = [ImageManipulator imageWithColor:[UIColor lightGrayColor] sizeX:sizeOfImage sizeY:sizeOfImage];
}else if( thisColor == @"Gray"){
colorImage = [ImageManipulator imageWithColor:[UIColor grayColor] sizeX:sizeOfImage sizeY:sizeOfImage];
}else if( thisColor == @"Red"){
colorImage = [ImageManipulator imageWithColor:[UIColor redColor] sizeX:sizeOfImage sizeY:sizeOfImage];
}else if( thisColor == @"Green"){
colorImage = [ImageManipulator imageWithColor:[UIColor greenColor] sizeX:sizeOfImage sizeY:sizeOfImage];
}else if( thisColor == @"Blue"){
colorImage = [ImageManipulator imageWithColor:[UIColor blueColor] sizeX:sizeOfImage sizeY:sizeOfImage];
}else if( thisColor == @"Cyan"){
colorImage = [ImageManipulator imageWithColor:[UIColor cyanColor] sizeX:sizeOfImage sizeY:sizeOfImage];
}else if( thisColor == @"Yellow"){
colorImage = [ImageManipulator imageWithColor:[UIColor yellowColor] sizeX:sizeOfImage sizeY:sizeOfImage];
}else if( thisColor == @"Magenta"){
colorImage = [ImageManipulator imageWithColor:[UIColor magentaColor] sizeX:sizeOfImage sizeY:sizeOfImage];
}else if( thisColor == @"Orange"){
colorImage = [ImageManipulator imageWithColor:[UIColor orangeColor] sizeX:sizeOfImage sizeY:sizeOfImage];
}else if( thisColor == @"Purple"){
colorImage = [ImageManipulator imageWithColor:[UIColor purpleColor] sizeX:sizeOfImage sizeY:sizeOfImage];
}else if( thisColor == @"Brown"){
colorImage = [ImageManipulator imageWithColor:[UIColor brownColor] sizeX:sizeOfImage sizeY:sizeOfImage];
}
UIImageView *colorImageView = [[UIImageView alloc] initWithImage:colorImage];
colorImageView.frame = CGRectMake(0, 0, sizeOfImage, sizeOfImage);
[colorImage release];
[colorImageArray addObject:colorImageView];
[colorImageView release];
}
NSArray *imageViewArray = [NSArray arrayWithArray:colorImageArray];
colorPropertyDef.attributes.imageViewArray = imageViewArray;
other methods
+ (UIImage *)imageWithColor:(UIColor *)color sizeX:(float)sizeX sizeY:(float)sizeY{
CGRect rect = CGRectMake(0.0f, 0.0f, sizeX, sizeY);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
But I receive a EXC_BAD_ACCESS error in the following block of SCTableViewModel.m :
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
SCTableViewCell *cell = [self cellAtIndexPath:indexPath];
if([cell.delegate conformsToProtocol:@protocol(SCTableViewCellDelegate)]
&& [cell.delegate respondsToSelector:@selector(willConfigureCell:)])
{
[cell.delegate willConfigureCell:cell];
}
else
if([self.delegate conformsToProtocol:@protocol(SCTableViewModelDelegate)]
&& [self.delegate
respondsToSelector:@selector(tableViewModel:willConfigureCell:forRowAtIndexPath:)])
{
[self.delegate tableViewModel:self willConfigureCell:cell forRowAtIndexPath:indexPath];
}
CGFloat cellHeight = cell.height;
// Check if the cell has an image in its section and resize accordingly
SCTableViewSection *section = [self sectionAtIndex:indexPath.section];
if([section.cellsImageViews count] > indexPath.row)
{
UIImageView *imageView = [section.cellsImageViews objectAtIndex:indexPath.row];
if([imageView isKindOfClass:[UIImageView class]])
{
if(imageView == nil){
NSLog(@"Image was nil");
cellHeight = 44.0f;
}else{
///////////////////////// ERROR at LINE BELOW // I think imageView has no size??
if(cellHeight < imageView.image.size.height)
cellHeight = imageView.image.size.height;
}
}
}
return cellHeight;
}