1
我有一个tableview与自定义单元格,它有2个标签,我更改选项卡和视图控制器编程方式我更新我的列表后我叫[tablview reloadData]
。但它只是更新一个标签的值。这里是的cellForRowAtIndexPath的代码:iOS:UITableviewController没有更新一个标签的值
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
TimesheetCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TimesheetCell"];
Timesheet *t = (self.timesheetArray)[indexPath.row];
cell.timesheetTitle.text = t.date;
cell.hours.text = [NSString stringWithFormat:@"%d", t.hours];
NSLog(@"%d", t.hours);
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
formatter.dateFormat = @"EEEE, MMMM d";
NSString *currentDate = [formatter stringFromDate:[NSDate date]];
NSLog(@"%@",t.date);
if([t.date isEqualToString:currentDate]){
cell.timesheetTitle.textColor = [UIColor colorWithRed:0 green:0.478431 blue:1.0 alpha:1.0];
cell.hours.textColor = [UIColor colorWithRed:0 green:0.478431 blue:1.0 alpha:1.0];
}
if(_changeCellToBlack)
{
cell.timesheetTitle.textColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:1.0];
cell.hours.textColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0];
}
if (indexPath.row == 7) {
[cell.timesheetTitle setFont:[UIFont fontWithName:@"Avenir-Black" size:19]];
[cell.hours setFont:[UIFont fontWithName:@"Avenir-Black" size:19]];
[cell setAccessoryType:UITableViewCellAccessoryNone];
if (t.hours < 40) {
cell.timesheetTitle.textColor = [UIColor redColor];
cell.hours.textColor = [UIColor redColor];
}
}
return cell;
}
时间标签没有更新它的价值,我已经登录从列表中包含小时的价值,价值。
向我们展示如何添加'hours'的UILabel的细胞。 – KlimczakM
我正在使用表视图控制器和我有一个自定义类的单元格'TimesheetCell',我创建了小时标签的IBOutlet属性。 –
确切的问题是什么?小时标签没有得到文字? – Lion