如何在Xcode中为tableview添加字幕

时间:2012-09-04 21:44:23

标签: iphone xcode ipad

如何在字幕中添加文字?目前我有一个名单列表的NSArray,如何为名称添加字幕?

   lodgeList = [[NSArray alloc]initWithObjects:

            @"Abingdon Lodge No. 48",
            @"York Lodge No. 12",
            @"Alberene Lodge No. 277",

             nil];

继续...

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

 if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}


cell.textLabel.text =[lodgeList objectAtIndex:indexPath.row];

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

return cell;

1 个答案:

答案 0 :(得分:2)

假设您使用的是标准UITableViewCell,请确保将表格单元格的样式设置为UITableViewCellStyleSubtitle,然后通过设置单元格的detailTextLabel.text属性来设置字幕文本。