2
你好嗎?我有一個奇怪的問題,我的tableviewcell。當我在模擬器上運行這個。這表明適當的佈局圖像1iOS 7 TableviewCell彩色線條
,但是當我在設備上運行此。它在應用程序的所有桌面上都有彩色線條,如圖像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);
}
}
你說:「當我在設備上運行它時,它顯示如圖1所示的正確佈局。」和:「但是當我在設備上運行它時,它在應用程序的所有桌面視圖中都有彩色線條,如圖像2。有什麼不同?你總是在設備上運行?或者你的意思是模擬器.. – Ilario
抱歉。我編輯過它。它是第一個模擬器。感謝您的意見。 – Saad
你可以在「 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath」或UITableViewCell的子類中發佈一些代碼(如果有的話)。 – KudoCC