Okay I am just totally too close to this I think. I have a tableview. In that table view everything is working except section 2 row 0.
AND -- before anyone asks...I know I am not using the *imgWordView (in the code below) and that is why the icons are not showing but i do not know where to add it to the subview so i can place it at coordinates in the cell... :)
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
if (indexPath.section == 2 && indexPath.row == 0)
{
cell = [self getCellContentViewForIconRow:CellIdentifier];
cell.backgroundColor = [UIColor grayColor];
}
else
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
}
}
The above code (except for my addition of of my section == 2 && indexPath.row == 0
) is normal and generic..
getCellContentViewForIconRow
is defined here:
- (UITableViewCell *) getCellContentViewForIconRow:(NSString *)cellIdentifier {
ResortsListViewController *resortsListViewController = [[ResortsListViewController alloc] init];
NSMutableArray *categoryArray = [resortsListViewController getCategoriesForLocation:[[locationData objectForKey:@"theid"]intValue]];
[resortsListViewController release];
CGRect CellFrame = CGRectMake(0, 0, 260, 60);
UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:CellFrame reuseIdentifier:cellIdentifier] autorelease];
cell.contentView.backgroundColor = [UIColor grayColor];
int x = 10;
int y = 10;
for (NSMutableDictionary *cat_object in categoryArray) {
CGRect Label1Frame = CGRectMake(x, y, x + 40, 40);
UILabel *lblTemp = [[UILabel alloc] initWithFrame:Label1Frame];
lblTemp.tag = x + 1;
NSString *filePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"alcohol.png"];
UIImage *imgWord = [[[UIImage alloc] initWithContentsOfFile:filePath] autorelease];
UIImageView *imgWordView = [[[UIImageView alloc] initWithImage:imgWord] autorelease];
[cell.contentView addSubview:lblTemp];
[lblTemp release];
x = x + 30;
}
return cell;
}
Okay, so
ResortsListViewController *resortsListViewController = [[ResortsListViewController alloc] init];
NSMutableArray *categoryArray = [resortsListViewController getCategoriesForLocation:[[locationData objectForKey:@"theid"]intValue]];
[resortsListViewController release];
gets back a group of categories that I would use to build the filenames for the PNG images. Everything is okay so far. Then I am looping through the array to build the places for the images in the cell.
I am expecting no more than 5 images...at 30x30 each. so, to test, I just used the filename "alcohol.png" which exists. I want all 5 images to be displayed in a row inside the cell
I already do this:
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 2 && indexPath.row == 0)
{
return 60;
}
}
But, all I see is my table cell (in gray like it is supposed to be) with a LONG white box inside it.
So, two questions.
1: The box (i am assuming it is the CGRect CellFrame = CGRectMake(0, 0, 260, 60);
) in white. I need to know how to change that to gray...just like my cell background.
The big reason is that my icons are white...and i cannot tell if the icons are visible or not.
If the only problem is that this white CGRECT is hiding my icons, then all is well.
Otherwise we come to #2:
2: Is this the best way to put a group of icons within a cell row when the icon names are inside an array?
If not, how?
So, How do i make the CGRect gray & how do i get the 5 icons to appear horizontally in the cell?
Thanks in advance for your help!