我一直在将应用程序从iOS6转换为iOS7,使用以下代码在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;
}在这里可以看到以UITableView为父级和以UINavigationController为父级的UINavigationController之间的区别:
常规与波波夫
请注意,在popover版本中不再见“显示箭头”,即使当我尝试增加popover的宽度时也是如此。弹出器中的单元格使用iPhone宽度。还请注意,标签的格式在单元格中是不正确的,但定位是否良好?
在原始iOS6版本中,popover版本显示UINavigationController版本的相同格式。
发布于 2013-10-04 11:27:44
通过添加:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { cell.backgroundColor = [UIColor whiteColor]; }
https://stackoverflow.com/questions/19042660
复制相似问题