我有以下代码,但在为UIImageView设置图像时出错:
[UITableViewCellContentView setImage:]: unrecognized selector sent to instance 0x17e87eb0'
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
//Get image for the row
UIImageView *imageView = (UIImageView *)[cell viewWithTag:100];
NSURL *photoURL = [NSURL URLWithString:@"http://server.com/someimage.jpg"];
UIImage *photo = [UIImage imageWithData:[NSData dataWithContentsOfURL:photoURL]];
imageView.contentMode = UIViewContentModeScaleAspectFit;
imageView.image = photo;
cell.textLabel.text = @"test";
return cell;
}
答案 0 :(得分:2)
问题在于您尝试将邮件setImage
发送到UITableViewCellContentView
,这只是UIView
并且没有图片属性。看起来你标记了细胞的错误部分。返回您的XIB或故事板,确保您已标记UIImageView
100。