首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UITableViewController在弹出窗口中的显示方式不同,为什么?

UITableViewController在弹出窗口中的显示方式不同,为什么?
EN

Stack Overflow用户
提问于 2013-09-27 04:21:13
回答 1查看 502关注 0票数 0

我一直在将应用程序从iOS6转换为iOS7,使用以下代码在UITableviewController中显示单元格

代码语言:javascript
复制
- (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版本的相同格式。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-10-04 11:27:44

通过添加:

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19042660

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档