ios - 在单元格中添加多个内容

标签 ios objective-c

我是 iphone devlpmnt 的新手。我只想在单元格中添加当前日期。我需要“notiftext”出现在单元格的左侧,当前日期出现在右侧。提前致谢

- (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;

}

最佳答案

使用任何其他样式的单元格或使用自定义单元格来完全自定义单元格。我认为对于您的问题 TableView 麦粒肿 UITableViewCellStyleValue1 就足够了。

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

关于ios - 在单元格中添加多个内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16827756/

相关文章:

ios - 如何给我的标签上课?

android - Unity3D 初学者和游戏设计

ios - 如何使 UILabel 调整大小以适合文本

iphone - 从 NSObject 属性读取自定义 NSObject

objective-c - 使用 NSOrderedSame 的目的是什么?

ios - 如何在ios中对NSMutableArray中的时间进行排序

ios - 如何在 Xamarin.iOS 中保护 cache.db 文件

ios - 从另一个 UIViewController 刷新表格

ios - 如何发出多个 GET 请求并等待所有操作完成?

iphone - 局部声明隐藏实例变量 - tableView 未合成