I am trying to create a table where each cell can be of variable height, and display different types of data.
For the height requirement I found this cool layout-engine called "Xib-free" ( http://www.toptensoftware.com/xibfree/uitableviewcell_variable ). I thought this would also help with different cell types, but alas their examples also only used one cell type.
I know multiple cell types is possible (e.g. one with just an image, one with just text, one with both, etc.) as I've seen many examples in Objective-C accomplish this using the following (taken from Calling two different custom cell in one UITableView issue):
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath {
if (indexPath.section == 0) {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1
reuseIdentifier:CellIdentifier];
}
containerObject = [objectCollection objectAtIndex:indexPath.row];
[[cell textLabel] setText:containerObject.store];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
} else {
static NSString* cellIdentifier1 = @"FeatureCell";
FeatureCell *cell1 = (FeatureCell*)[tableView dequeueReusableCellWithIdentifier:cellIdentifier1];
if (cell1 == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:cellIdentifier1 owner:nil options:nil];
cell1 = (FeatureCell*)[nib objectAtIndex:0];
}
cell1.img1.image = [UIImage imageNamed:@"shower.png"];
cell1.img2.image = [UIImage imageNamed:@"parking.png"];
return cell1;
}
}
Of course there isn't a cellForRowAtIndexPath in Monotouch, but I'm fairly certain this can be achieved with GetCell. I say fairly certain because I have not been able to get this to work.
Here's my thought process:
-A different custom cell class for each cell type I want
-in the GetCell method, I would add each cell depending on the NSIndex, similar to the code above.
Another thing I am trying to accomplish is have once cell type only contain an image. I'm not sure of how to go about doing this since the styles for cells involve text only or text with an image to the left.
This is a great example of what I am trying to accomplish: http://img0.mobile-patterns.com/img/full/1386265829522-2013-12-03%2020.35.26.png
I'm sorry for the lengthy question but I could really use some help. I feel I am very close in the thought process, but need some guidance. Thank you very much in advance.