UITableViewController 在弹出窗口中显示不同,为啥?
Posted
技术标签:
【中文标题】UITableViewController 在弹出窗口中显示不同,为啥?【英文标题】:UITableViewController displays differently in a popover, why?UITableViewController 在弹出窗口中显示不同,为什么? 【发布时间】:2013-09-27 04:21:13 【问题描述】:我一直在将应用从 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
作为父级然后作为弹出窗口之间的区别如下所示:
Regular & Popover
请注意,即使在我进行实验时,弹出框版本中也不再显示“披露”箭头 随着弹出框宽度的增加。弹出框中的单元格使用 iPhone 宽度。 另请注意单元格中标签的格式不正确,但定位 好吗?
在iOS6原版中,popover版本显示的格式与UINavigationController
版本相同。
【问题讨论】:
通过添加解决:- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath cell.backgroundColor = [UIColor whiteColor]; 请回答您自己的问题并接受。 冷静下来,在写评论的时候,我在沙漠中的互联网连接很差。 为什么是消极态度?刚刚提议你回答你的问题? 【参考方案1】:通过添加解决:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath cell.backgroundColor = [UIColor whiteColor];
【讨论】:
以上是关于UITableViewController 在弹出窗口中显示不同,为啥?的主要内容,如果未能解决你的问题,请参考以下文章
当我触摸后退按钮时,为啥 UINavigationController 不弹出 UITableViewController?
如果弹出框作为模型呈现,UITableViewController 将失去滚动功能