【发布时间】:2013-12-13 09:43:13
【问题描述】:
你们好吗。我的 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 sublcasm方法进行更新。
-(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);
}
}
【问题讨论】:
-
你说:“当我在设备上运行它时。它显示了正确的布局,如图 1 所示。”并且:“但是当我在设备上运行它时。它在应用程序的所有表格视图中都有彩色线条,如图 2 所示。”有什么不同?你总是在设备上运行?或者你的意思是模拟器..
-
哎呀抱歉。我已经编辑过了。这是第一个模拟器。谢谢你的意见。
-
你能在“- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath”或者你的UITableViewCell的子类中发布一些代码吗?
-
我已经添加了。查看更新的问题
-
检查您正在使用的图像。非视网膜是否正常而视网膜图像是否错误(反之亦然)。此外,
nil图像,如果它不是第一个或最后一个(记住单元格正在被重复使用)。
标签: ios iphone xcode uitableview