在单元格中添加多个内容

时间:2013-05-30 04:07:04

标签: ios objective-c

我是iphone开发的新手。我只想在单元格中添加当前日期。我需要在单元格左侧显示“通知文本”,在右侧显示当前日期。提前谢谢

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

AppDelegate *AppD = (AppDelegate *)[[UIApplication sharedApplication]delegate];

static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if(cell == nil) {

    cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier]autorelease];

}



MLNotifMessage *list = [AppD.storage objectAtIndex:indexPath.row];
cell.textLabel.text = list.notifText;

NSString *dteStr = [[NSString alloc]init];

NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];

[dateFormat setTimeZone:[NSTimeZone timeZoneWithName:@"Europe/London"]];

[dateFormat setDateFormat:@"dd/MM/yyyy HH:mm:ss"];

dteStr = [dateFormat stringFromDate:list.date];

[dateFormat release];

cell.detailTextLabel.text = dteStr;
return cell;

}

2 个答案:

答案 0 :(得分:2)

使用任何其他样式的单元格或使用自定义单元格来完全自定义单元格。我认为对于你的问题tabel view stye UITableViewCellStyleValue1就足够了。

  cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier]autorelease];
  cell.textLabel.text = list.notifText;
  cell.detailTextLabel.text = [NSDate date];

答案 1 :(得分:0)

使用Custom TableViewCell。您可以通过继承它来创建自定义tableViewCell

相关问题