I have been converting an app from iOS6 to iOS7, using the following code to display cells in a UITableviewController
:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
PCApplicationCell *cell = (PCApplicationCell*)[tableView dequeueReusableCellWithIdentifier:kCellIdentifier];
if (cell == nil)
{
if(indexPath.section == 0 || indexPath.section == 2)
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone || self.PopOver)
self.cellNib = [UINib nibWithNibName:@"PCChooseSubviewsBasedApplicationCell_iPhone" bundle:nil];
else
self.cellNib = [UINib nibWithNibName:@"PCChooseSubviewsBasedApplicationCell_iPad" bundle:nil];
}
else
{
if(indexPath.row == 1)
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone || self.PopOver)
self.cellNib = [UINib nibWithNibName:@"PCEditSubviewsBasedApplicationCell_iPhone" bundle:nil];
else
self.cellNib = [UINib nibWithNibName:@"PCEditSubviewsBasedApplicationCell_iPad" bundle:nil];
}
else
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone || self.PopOver)
self.cellNib = [UINib nibWithNibName:@"PCSwitchSubviewsBasedApplicationCell_iPhone" bundle:nil];
else
self.cellNib = [UINib nibWithNibName:@"PCSwitchSubviewsBasedApplicationCell_iPad" bundle:nil];
}
}
[self.cellNib instantiateWithOwner:self options:nil];
cell = tmpCell;
self.tmpCell = nil;
[cell setDelegate:self];
}
// get the view controller's info dictionary based on the indexPath's row
NSDictionary* itemSection = [self.listContent objectAtIndex:indexPath.section];
NSArray* groupItems = [itemSection objectForKey:kChildrenKey];
NSDictionary* item = [groupItems objectAtIndex:indexPath.row];
cell.help = [item objectForKey:kItemHelpKey];
cell.helpcontents = [item objectForKey:kHelpChildrenKey];
cell.tag = indexPath.row;
cell.name = [item objectForKey:kItemTitleKey];
cell.value = @"";
if(indexPath.section == 1)
{
if(indexPath.row == 1)
{
cell.value = [NSString stringWithFormat:@"%d ", [config.MDepthIntervalInTCPlot intValue]];
cell.tag = 0;
}
else
{
UISwitch *switchControl = [[UISwitch alloc] initWithFrame:CGRectMake(1.0, 1.0, 20.0, 20.0)];
[switchControl addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventValueChanged];
if([config.MDepthsInTCPlot boolValue])
switchControl.On = YES;
else
switchControl.On = NO;
switchControl.tag = 0;
cell.accessoryView = switchControl;
switchControl = nil;
}
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
The differences between the UITableView
with UINavigationController
as parent and then as popover is seen here:
Notice the Disclosure arrow no longer seen in popover version, even when I experiment with increasing width of popover. The cells in the popover use iPhone widths. Also notice the formatting of the labels in the cells is not correct, yet positioning is good?
In the original iOS6 version, the popover version displays the same formatting of the UINavigationController
version.