Reputation: 11452
I have been trying various methods with no success to alter the following code...
I have a nib file that works fine if I set all cells to this but I only want one of the switch statements to have the custom cell nib file. Any ideas?
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger row = [indexPath row];
NSInteger section = [indexPath section];
UITableViewCell *cell;
switch (section)
{
case 0:
cell = [tableView dequeueReusableCellWithIdentifier:@"any-cell"];
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"any-cell"] autorelease];
cell.text = [showTimes objectAtIndex:row];
break;
case 1:
cell = [tableView dequeueReusableCellWithIdentifier:@"any-cell"];
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"any-cell"] autorelease];
cell.text = [showTimes objectAtIndex:row];
break;
default:
cell = [tableView dequeueReusableCellWithIdentifier:@"any-cell"];
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"any-cell"] autorelease];
cell.text = [showTimes objectAtIndex:row];
break;
}
return cell;
}
Upvotes: 1
Views: 12782
Reputation: 19071
You're going to need to do two things:
initWithFrame:reuseIdentifier:
method, you need to initialize the cell from your nib. Check Apple's Table View Programming Guide's section on using nibs.Also, though this isn't technically required, UITableViewCell's initWithFrame:reuseIdentifier:
method has been deprecated in favor of initWithStyle:reuseIdentifier:
.
Upvotes: 7