如何在NSMutableArray的UITableViewCell中显示图像?
我正在这样做:如何在NSMutableArray的UITableViewCell中显示图像?,uitableview,uiimage,nsmutablearray,arrays,Uitableview,Uiimage,Nsmutablearray,Arrays,我正在这样做: (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell
(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];
cell.imageView.image = [UIImage imageNamed:[[self.articlesArray
objectAtIndex:indexPath.row]objectForKey:@"images"]];
// [cell.imageView setImageWithURL:[NSURL URLWithString:[[self.articlesArray
objectAtIndex:indexPath.row]objectForKey:@"images"]]];
}
return cell;
}
我正在这样做:
cell.imageView.image = [UIImage imageNamed:[[self.articlesArray
objectAtIndex:indexPath.row]objectForKey:@"images"]];
但是我的UITableViewCell
中没有显示任何内容
我想在左侧的tableViewCell
左侧显示图像
请告诉我怎么做。我自己做的 这是一个解决方案,它非常有效
NSData* imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:
[[self.articlesArray objectAtIndex:indexPath.row]objectForKey:@"images"]]];
UIImage* image = [[UIImage alloc] initWithData:imageData];
cell.imageView.image =image;
请确认
self.articlesArray
已初始化,每个条目都包含一个带有键“images”的字典,键“images”指向一个NSString,并且图像存在于主捆绑包中(因为您使用的是imageNamed:
).yes self.articlesArray已初始化,每个条目都包含一个dict,其中的键“images”指向如下NSString“”您发布的URL不完整。尝试将[UIImage imageNamed:][/code>的返回值设置为变量,并通过调试验证该值是否为零。