你好。我的tableviewcell有一个奇怪的问题。当我在模拟器上运行它时。它显示了正确的布局,如图1所示。
但是当我在设备上运行它时。它在应用的所有工作表视图中都有彩色线条,如图像2.
这是iOS 7的问题吗?我在tablview中清除了单元格的背景颜色:willDisplayCell:。
代码是
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
BarsCustomCell *cell= [BarsCustomCell resuableCellForTableView:tableView withOwner:self];
Bars *currentValue= [self.data objectAtIndex:indexPath.row];
if(indexPath.row==(self.data.count-1)){
[cell updateWithBars:currentValue isLast:YES isFirst:NO] ;
}else if (indexPath.row==0){
[cell updateWithBars:currentValue isLast:NO isFirst:YES] ;
}else{
[cell updateWithBars:currentValue isLast:NO isFirst:NO] ;
}
}
和Tableviewcell sublcassm方法进行更新。
-(void) updateWithBars:(Bars *)bars isLast:(BOOL)isLast isFirst:(BOOL)isFirst{
self.nameLbl.text= bars.name;
self.addressLbl.text= bars.vicinity;
double distance = [[[LOTVLocationManager sharedManager] mockedLocation] distanceFromLocation:bars.location];
self.distanceLbl.text= [NSString stringWithFormat:@"%.2f km",distance/1000];
if(isFirst){
self.bgImageview.image= [UIImage imageNamed:@"sport_top_bg.png"];
self.nameLbl.center= CGPointMake(self.nameLbl.center.x, self.nameLbl.center.y+3);
}
else if(isLast){
self.bgImageview.image= [UIImage imageNamed:@"sport_bottom_bg.png"];
self.addressLbl.center= CGPointMake(self.addressLbl.center.x, self.addressLbl.center.y-3);
}
}
答案 0 :(得分:0)
解决了这个问题。这是由于TableviewCell的背景色。某些iOS版本支持cell.backgroundColor,有些仅支持cell.contentView.backgroundColor。我为cell和contentView写了两个来修复这个问题。