我有一个UIScrollView,里面有一个小UITableView。在iOS-7中,一切都工作得很完美,但在iOS-6中,表视图根本不显示,完全不可见。所有东西都被实例化,委托和数据源方法被调用,但是UITableView没有出现。空白处什么都没有。
有人知道为什么会发生这种事吗?
更新:
它只是带有本机单元格的原生UITableView。
下面是一些示例代码:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [_gridTableData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *gridCellId = @"gridCellID";
UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:gridCellId];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:gridCellId];
[cell.textLabel setFont:[UIFont fontWithName:@"HelveticaNeue" size:12]];
[[cell textLabel] setText:_gridTableNames[[indexPath row]]];
[cell.detailTextLabel setFont:[UIFont fontWithName:@"HelveticaNeue" size:12]];
[[cell detailTextLabel] setText:_gridTableData[[indexPath row]]];
}
return cell;
}发布于 2014-02-14 13:34:46
在一些推荐的日志语句之后,我发现了问题所在:
在iOS6中,UITableView的帧的高度变为0。在"viewDidLoad“期间,高度是正确的(94p),但在此之后,高度始终为0。
但我真的不知道为什么会这样。在iOS7中,UITableView的高度从不改变。
例如,我可以通过在"viewDidLayoutSubviews“中重新设置UITableView的帧高来”修复“它。但是,如果任何人有一个干净的方法解决这个问题,或知道这种行为的根源,它将是值得赞赏的。
发布于 2014-02-13 21:46:13
请记住,在iOS 7中,默认情况下,单元格的背景是白色的。在6和更早的时候它是透明的。这意味着,如果在覆盖黑色背景的表中有黑色文本,它将在6或更早的时间内不可见。(看一些屏幕截图会有帮助。)
https://stackoverflow.com/questions/21765025
复制相似问题