UITableView和select项目

我目前正在创build一个简单的分组的UITableView,当用户select例如“苹果”,我想我的项目中的图像被加载到苹果的图像视图。

我在互联网上看到了一些例子,但我想看看还有什么。

任何build议将不胜感激。 谢谢。

或者设置cell.imageView.highlightedImage ,或者在didSelectRowAtIndexPath方法中,将cell.imageView.image从nil改为某些[UIImage imageNamed:@"myImage.png"]

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *kCustomCellID = @"com.me.foo.cell"; UITableViewCell *cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCustomCellID] autorelease]; cell.textLabel.highlightedTextColor = [UIColor blueColor]; cell.imageView.image = nil; cell.imageView.highlightedImage = [UIImage imageNamed:@"myImage.png"]; return cell; } - (void)tableView:(UITableView *)tableView willDisplayCell:(iPadRootViewControllerTableCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { cell.imageView.contentMode = UIViewContentModeScaleAspectFit; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // Do this if you didnt set the highlightedImage in cellForRowAtIndexPath // [self tableView:tableView cellForRowAtIndexPath:indexPath].imageView.image = [UIImage imageNamed:@"myApple.png"]; }