Hi,
I have one UITableView which I want to have three sections - all of which are made up of custom cells.
The first section needs to be the normal cell height and width, but the second section (with the Tweets, Followers etc.) I want to fit two rows in one row like in the second section in the image below. I've tried changing the width of the cells, but it doesn't work.
I've pasted the code below to display the cells, but at the moment it doesn't throw any errors just doesn't do what I want it to do! (It also has a warning of "control reaches end of non-void function though at the } after the final return cell.
The image (the second "Tweets, Followers etc." section is the one I want to re-create):
And the code: - (UITableViewCell *)tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if(indexPath.section==0) {
static NSString *kCellIdentifier = @"SongDetailCell";
UITableViewCell *cell = (UITableViewCell *)[self.tableView dequeueReusableCellWithIdentifier:kCellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:kCellIdentifier] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
switch (indexPath.row) {
case 0: {
cell.textLabel.text = NSLocalizedString(@"District:", @"district label");
cell.detailTextLabel.text = dog.district;
} break;
case 1: {
cell.textLabel.text = NSLocalizedString(@"Location:", @"location label");
cell.detailTextLabel.text = dog.locations;
} break;
case 2: {
cell.textLabel.text = NSLocalizedString(@"Dog Name:", @"name label");
cell.detailTextLabel.text = dog.names;
} break;
case 3: {
cell.textLabel.text = NSLocalizedString(@"Last Updated:", @"last updated label");
cell.detailTextLabel.text = [incident.lastUpdated substringToIndex:[dog.lastUpdated length] - 1];
} break;
case 4: {
cell.textLabel.text = NSLocalizedString(@"Type:", @"type label");
cell.detailTextLabel.text = dog.types;
} break;
case 5: {
cell.textLabel.text = NSLocalizedString(@"Status:", @"status label");
cell.detailTextLabel.text = dog.status;
} break;
case 6: {
cell.textLabel.text = NSLocalizedString(@"Size:", @"size label");
cell.detailTextLabel.text = dog.sizes;
} break;
case 7: {
cell.textLabel.text = NSLocalizedString(@"Applicances:", @"appliances label");
cell.detailTextLabel.text = dog.appliances;
} break;
case 8: {
cell.textLabel.text = NSLocalizedString(@"Started:", @"started label");
cell.detailTextLabel.text = dog.startDate;
} break;
}
return cell;
}
if(indexPath.section==1) {
static NSString *CellIdentifier = @"ContactCell";
ContactViewCell *cell = (ContactViewCell *)
[self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"ContactTableCell" owner:self options:nil];
for (id currentObject in topLevelObjects){
if ([currentObject isKindOfClass:[UITableViewCell class]]){
cell = (ContactViewCell *) currentObject;
break;
}
}
switch (indexPath.row) {
case 0: {
cell.testLabel.text = @"Title";
} break;
case 1: {
cell.testLabel.text = @"Title";
} break;
case 2: {
cell.testLabel.text = @"Title";
} break;
case 3: {
cell.testLabel.text = @"Title";
} break;
case 4: {
cell.testLabel.text = @"Title";
} break;
}
return cell;
}
}