UIImage未显示图像。我使用以下方法为表单元创建了UIImageView自定义类:

imgView = [[UIImageView alloc]init];
frame= CGRectMake(boundsX+10 ,0, 50, 44);
imgView.frame = frame;

然后,我尝试加载每个单元,什么也不加载。但是,我能够读取日志消息中的图像URL。
NSURL *url = [NSURL URLWithString: [dict objectForKey:@"imageAdd"]];
NSData *data = [NSData dataWithContentsOfURL: url];
UIImage * image = [[UIImage alloc] initWithData:[[data copy] autorelease]];
NSLog (@"The image is located at the URL: %@", url);
cell.imgView.image = image;
return cell;

最佳答案

据我从您的代码中看到的那样,您从未添加imgView作为单元格的子视图。添加行:

[cell.contentView addSubview:imgView];

关于ios - UIImageView无法显示图像,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13348080/

10-08 20:38