Ios UITableViewCell显示UIImage中的图像
我正在创建带有文件名和缩略图列表的tableView。我不知道;文件名没有问题,但是当我将UIImage数组传递给tabeView时,我发现了一个错误,下面是一个代码:Ios UITableViewCell显示UIImage中的图像,ios,uitableview,Ios,Uitableview,我正在创建带有文件名和缩略图列表的tableView。我不知道;文件名没有问题,但是当我将UIImage数组传递给tabeView时,我发现了一个错误,下面是一个代码: cell.imageView.image = [UIImage imageNamed:[arrayColletionImages objectAtIndex:indexPath.row]]; ArrayCollectionImages我从以下位置获得的图像: player = [[MPMoviePlayerController
cell.imageView.image = [UIImage imageNamed:[arrayColletionImages objectAtIndex:indexPath.row]];
ArrayCollectionImages我从以下位置获得的图像:
player = [[MPMoviePlayerController alloc] initWithContentURL:url];
thumbnail = [player thumbnailImageAtTime:0.0 timeOption:MPMovieTimeOptionExact];
[player stop];
[arrayColletionImages addObject:thumbnail];
所有UITableViewCell代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"SimpleTableItem";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.textLabel.text = [tableData objectAtIndex:indexPath.row];
cell.imageView.image = [UIImage imageNamed:[arrayColletionImages objectAtIndex:indexPath.row]];
NSLog(@"%@",indexPath);
return cell;
}
数组不能包含UIImage对象。请在数组中记录该值 日志中的
表示它是一个UIImage对象,在cellForRow
代码中,您再次将其用作
cell.imageView.image = [UIImage imageNamed:[arrayColletionImages objectAtIndex:indexPath.row]];
UIImage-imageNamed:
需要一个NSString而不是UIImageso
去掉这个
cell.imageView.image = [UIImage imageNamed:[arrayColletionImages objectAtIndex:indexPath.row]];
在代码中尝试这个
[cell.imageView setImage:[arrayColletionImages objectAtIndex:indexPath.row]];
请试着用这个。您正在从数组访问图像名称,但是您已经在此数组中存储了
UIImage
对象,因此无需调用imageNamed:
所以写这行
cell.imageView.image = [arrayColletionImages objectAtIndex:indexPath.row];
得到的错误是什么?在哪一行中得到的错误?得到的错误是什么?cell.imageView.image=[UIImage ImageName:[arrayColletionImages objectAtIndex:indexPath.row];您可以
NSLog(@“映像名称:%@,[ArrayCollectionImages对象索引:indexPath.row])代码>你得到答案了吗?谢谢,排序好了。它也适用于此代码。你是陆路交通大学的吗?