Мой UITableView отображает переменные данные из веб-службы SOAP. Последняя строка показывает итоговые значения. Как я могу дать только Последняя строка в TableView сером фоне?Backcolor только последняя строка UITableView
Это то, что у меня есть:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"UITableViewCell"];
}
NSString *basis = [chunks objectAtIndex:indexPath.row];
NSArray *words2 = [basis componentsSeparatedByString:@":"];
for (NSString *word2 in words2) {
[chunks2 addObject:word2];
}
NSString *artikelnaamfull = @" ";
if ([words2 count] > 2) artikelnaamfull = [words2 objectAtIndex:2];
NSString *aantal = @" ";
if ([words2 count] > 2) aantal = [words2 objectAtIndex:6];
NSString *prijsex = @" ";
if ([words2 count] > 2) prijsex = [words2 objectAtIndex:7];
NSString *artikelnaam = [artikelnaamfull stringByReplacingOccurrencesOfString:@"Omschr =" withString:@""];
if ([artikelnaamfull isEqualToString:@" "]) {
artikelnaam = [words2 objectAtIndex:0];
artikelnaam = [artikelnaam stringByReplacingOccurrencesOfString:@"Totalex= " withString:@"Totaal excl. BTW: € "];
artikelnaam = [artikelnaam stringByReplacingOccurrencesOfString:@"Totalin= " withString:@"Totaal incl. BTW: € "];
cell.contentView.backgroundColor = [UIColor grayColor];
cell.textLabel.backgroundColor = [UIColor grayColor];
cell.textLabel.text = artikelnaam;
cell.detailTextLabel.text = @"";
} else {
aantal = [aantal stringByReplacingOccurrencesOfString:@"Aantal=" withString:@""];
prijsex = [prijsex stringByReplacingOccurrencesOfString:@"Exclusief=" withString:@""];
prijsex = [prijsex stringByReplacingOccurrencesOfString:@"," withString:@"."];
double value = [prijsex doubleValue];
int value2 = [aantal doubleValue];
double totaal = value2 * value;
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setMaximumFractionDigits:2];
NSString *totaal2 = [formatter stringFromNumber:[NSNumber numberWithFloat:totaal]];
cell.textLabel.text = artikelnaam;
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@ verkocht x € %.2f € %@",aantal,value,totaal2];
}
return cell;
}
Что нужно добавить или изменить, чтобы сделать это?
Спасибо!
Просто установите ячейки 'backgroundColor' в' Tableview: willDisplayRowAtIndexPath: 'метод. Не забудьте установить цвет фона для ВСЕХ ячеек, чтобы вы не увидели странных результатов по мере прокрутки таблицы. – rmaddy
Как это сделать? –