首先H文件,定义变量: NSArray *arryData; NSIndexPath *parserSelection; SongsViewController *songsViewController; M文件,代码如下: - (void)viewWillAppear:(BOOL)animated { arryData = [[NSArray alloc] initWithObjects:@"测试1",@"测试2",@"测试3",@"测试4",@"测试5",@"测试6",@"测试7",nil]; } - (NSUInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSUInteger)section { return 7; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString * const kCellIdentifier = @"MyCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCellIdentifier] autorelease]; } if ([arryData objectAtIndex:indexPath.row] == @"测试1") { cell.imageView.image = [UIImage imageNamed:@"yaowen.png"]; }else if ([arryData objectAtIndex:indexPath.row] == @"测试2") { cell.imageView.image = [UIImage imageNamed:@"caijing.png"]; }else if ([arryData objectAtIndex:indexPath.row] == @"测试3") { cell.imageView.image = [UIImage imageNamed:@"yule.png"]; }else if ([arryData objectAtIndex:indexPath.row] == @"测试4") { cell.imageView.image = [UIImage imageNamed:@"tiyu.png"]; }else if ([arryData objectAtIndex:indexPath.row] == @"测试5") { cell.imageView.image = [UIImage imageNamed:@"guoji.png"]; }else if ([arryData objectAtIndex:indexPath.row] == @"测试6") { cell.imageView.image = [UIImage imageNamed:@"dajianshi.png"]; }else if ([arryData objectAtIndex:indexPath.row] == @"测试7") { cell.imageView.image = [UIImage imageNamed:@"tianqi.png"]; } cell.textLabel.text = [arryData objectAtIndex:indexPath.row]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { self.parserSelection = indexPath; [self.songsViewController parseWithParserType:self.parserSelection.row]; self.songsViewController.viewlabel = [arryData objectAtIndex:indexPath.row]; [self.navigationController pushViewController:self.songsViewController animated:YES]; [tableView deselectRowAtIndexPath:indexPath animated:YES]; }