0
votes

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:

Regular & Popover

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.

1
Solved by Adding :- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { cell.backgroundColor = [UIColor whiteColor]; }swainwri
Please answer your own question and accept.Leo Natan
chill out, I was on a poor internet connection in the desert at the time of writing comment.swainwri
Why the negative attitude? Just proposed you answer your question?Leo Natan

1 Answers

0
votes

Solved by Adding :

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