0

我一直在将应用程序从 iOS6 转换为 iOS7,使用以下代码在 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;
}

UITableView在这里可以看到with UINavigationControlleras parent 和 then as popover之间的区别:

常规和弹出框

请注意,即使我尝试增加 popover 的宽度,在 popover 版本中也不再显示 Disclosure 箭头。弹出框中的单元格使用 iPhone 宽度。还要注意单元格中标签的格式不正确,但定位是否正确?

在 iOS6 原版中,popover 版本显示的格式与UINavigationController版本相同。

4

1 回答 1

0

通过添加解决:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { cell.backgroundColor = [UIColor whiteColor]; }

于 2013-10-04T11:27:44.053 回答