向此UITableView添加说明

时间:2014-01-03 04:15:14

标签: ios objective-c uitableview

我正在制作一个涉及UITableView的应用。我目前只有一个标题,但我也需要它的描述。这是我设置表格视图单元格标题的代码,

 tableData = [NSArray arrayWithObjects:@"WIMPS", @"Mushroom Risotto", @"Full Breakfast", @"Hamburger", @"Ham and Egg Sandwich", @"Creme Brelee", @"White Chocolate Donut", @"Starbucks Coffee", @"Vegetable Curry", @"Instant Noodle with Egg", @"Noodle with BBQ Pork", @"Japanese Noodle with Pork", @"Green Tea", @"Thai Shrimp Cake", @"Angry Birds Cake", @"Ham and Cheese Panini", nil];

由此,我需要设置单元格的描述文本。谢谢你的帮助:D

1 个答案:

答案 0 :(得分:1)

代码就像这样

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

    }

    BookDetail * objBook= [self.arrBookRecords objectAtIndex:indexPath.row];
    cell.textLabel.text = [NSString stringWithFormat:@"%@  %@",objBook.bookname,objBook.author];

    [cell.detailTextLabel setAlpha:1.0];
    [cell.detailTextLabel setTextColor:[UIColor redColor]];
    cell.detailTextLabel.text=@"ravindra";

    return cell;

}

Sweet&简单的编码..........