tableView实现添加多个图片



 

@implementation SimpleTableViewController

{

    NSArray * tableData;

    NSArray * thumbnails;

    NSString * prepTime;

    NSArray * time;

}

 

 

- (void)viewDidLoad

{

    [super viewDidLoad];

    //Initialize table data

    tableData = [NSArray arrayWithObjects:@"Egg Benedict",@"Mushroom Risotto",@"Full Breakfast",@"Hamburger",@"Ham and Egg sandwith",@"Creme Brelee",@"White Chcolate Dount",@"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];

 

    //Initialize thumbnails

    thumbnails = [NSArrayarrayWithObjects:@"egg_benedict.jpg",@"mushroom_risotto.jpg",@"full_breakfast.jpg",@"hamburger.jpg",@"ham_and_egg_sandwich.jpg",@"creme_brelee.jpg",@"white_chocolate_donut.jpg",@"starbucks_coffee.jpg",@"vegetable_curry.jpg",@"instant_noodle_with_egg.jpg",@"noodle_with_bbq_pork.jpg",@"japanese_noodle_with_pork.jpg",@"green_tea.jpg",@"thai_shrimp_cake.jpg",@"angry_birds_cake.jpg",@"ham_and_cheese_panini.jpg"nil];

 

    //Initialize prepTime

    prepTime = @"PrepTime:";

 

    //Initialize time

    time = [NSArray arrayWithObjects:@"30 min",@"20 min",@"10 min",@"40 min",@"50 min",@"70 min",@"90 min",@"30 min",@"30 min",@"30 min",@"30 min",@"30 min",@"30 min",@"30 min",@"30 min",@"30 min",nil];


}



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

{

    static NSString *simpleTableIdentifier = @"SimpleTableCell";

 

    SimpleTableCell *cell = (SimpleTableCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

 

    if (cell == nil) {

        NSArray *nib = [[NSBundle mainBundle]loadNibNamed:@"SimpleTableCell" owner:self options:nil];

        cell = [nib objectAtIndex:0];

    }

    cell.nameLabel.text = [tableData objectAtIndex:indexPath.row];

    cell.thumbnailImageView.image = [UIImage imageNamed:[thumbnails objectAtIndex:indexPath.row]];

    cell.prepTimeLabel.text = prepTime;

    cell.time.text = [time objectAtIndex:indexPath.row];

 

    return cell;

}




你可能感兴趣的:(IOS)