自定义UItableView在ios8上未正确显示

自定义UItableView在ios8上未正确显示,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我制作了一个自定义的UITableViewCell,当我显示它时,我得到了这个结果(我在iPhone 5上运行xcode 6和iOS 8 beta 1) 当我旋转我的设备,然后旋转回肖像,一切都变得正确 请注意,当我使用xcode 5编译我的应用程序时,我没有遇到任何问题 cellforrowatinexpath: BGTCoursCell1 *cell = (BGTCoursCell1 *)[tableView dequeueReusableCellWithIdentifier:@"Cel

我制作了一个自定义的
UITableViewCell
,当我显示它时,我得到了这个结果(我在iPhone 5上运行xcode 6和iOS 8 beta 1)

当我旋转我的设备,然后旋转回肖像,一切都变得正确

请注意,当我使用xcode 5编译我的应用程序时,我没有遇到任何问题

cellforrowatinexpath:

BGTCoursCell1 *cell = (BGTCoursCell1 *)[tableView dequeueReusableCellWithIdentifier:@"Cell"];
NSArray  *nib = [[NSBundle  mainBundle] loadNibNamed:@"BGTCoursCell1" owner:self options:nil];
cell = [nib objectAtIndex:0];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"HH:mm"];
NSLocale *locale = [NSLocale currentLocale];
[dateFormatter setLocale:locale];

if (indexPath.section == 0)
{
   BGTCours *cours = [[currentDay coursMatin] objectAtIndex:indexPath.row];
    cell.matiereLabel.text = [cours matiere];
    cell.salleLabel.text = [cours salle];
    cell.heureLabel.text = [NSString stringWithFormat:@"De %@ à %@", [dateFormatter stringFromDate:[cours beginDate]], [dateFormatter stringFromDate:[cours endDate]]];
}
else
{
   BGTCours *cours = [[currentDay coursAprem] objectAtIndex:indexPath.row];
    cell.matiereLabel.text = [cours matiere];
    cell.salleLabel.text = [cours salle];
    cell.heureLabel.text = [NSString stringWithFormat:@"De %@ à %@", [dateFormatter stringFromDate:[cours beginDate]], [dateFormatter stringFromDate:[cours endDate]]];
}
return cell;

谢谢

尝试重新使用单元格,如更改:

BGTCoursCell1 *cell = (BGTCoursCell1 *)[tableView dequeueReusableCellWithIdentifier:@"Cell"];
NSArray  *nib = [[NSBundle  mainBundle] loadNibNamed:@"BGTCoursCell1" owner:self options:nil];
cell = [nib objectAtIndex:0];


我可能会晚一点参加聚会,但我今天(2014年6月26日)遇到了与iOS 8 beta 2和xCode 6 beta 2完全相同的问题,我发现他们仍然没有修复这个bug


xCode 6 beta版还有另一个bug,那就是我的应用程序无法正确请求GPS位置-它根本不会请求许可。这也可以通过切换回xCode 5来解决。我认为目前使用xCode 5构建和测试应用程序更可行。

您需要从
表视图返回
CGFloat
:heightforrowatinexpath:
。如果使用相同的方法返回浮点值,则会出现所看到的错误:

//causes the bug
-(float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    //...
}

//fixes the bug
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return tableView.rowHeight; // whatever
}

我有一个稍微类似的问题,并通过使用
cell.clipsToBounds=YES

这个问题有一个公认的答案,但我有一个相同的问题,这个问题没有被公认的答案解决,它告诉我们将
float
更改为
CGFloat

我发现使用基于表的
行高的代码的人也可能有这个问题。在iOS8中,重要的是查看
EstimatedRowheaight
而不仅仅是
rowHeight


当我在以编程方式生成的
UITableView
中使用这些变量时,修复这些变量解决了问题。

显示一些用于显示数据的代码?编辑,感谢您的时间。我也遇到了同样的问题:/Thank修复了我的问题iOS 8 beta 5Nice。在iOS 8 beta 5上也修复了我的问题。谢谢你的解决方案!在ios8 Beta5上对我进行了修复这在ios8的发布版本中对我不起作用这在ios8的发布版本中对我也不起作用,但frankish answer确实起到了作用。这并没有解决问题,只是隐藏了问题:你想要显示的内容在被剪切时不再可见。(如果你没有显示任何内容,如果你的字体很小,你可能看不到区别)我还必须创建自己的
-(CGFloat)tableView:(UITableView*)tableView estimatedHeightForHeaderInSection:(NSInteger)section
方法使其工作。
//causes the bug
-(float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    //...
}

//fixes the bug
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return tableView.rowHeight; // whatever
}