UIImageView *v = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, _msg.contentF.size.width, _msg.contentF.size.height)];
[v setImageWithURL:[NSURL URLWithString:_msg.msg]];
CGImageRef imgRef= [v.image CGImage];
CGFloat w= CGImageGetWidth(imgRef);
CGFloat h =CGImageGetHeight(imgRef);
CGFloat width,hight;
if (h>0.01){
if (w>h){
width =200;
hight = 200*h/w;
}else{
hight=200;
width =200*w/h;
}
}
// [v.image resizedImageToSize:CGSizeMake(width, hight)];
v.contentMode = UIViewContentModeScaleAspectFit;
if (w==0) {
width =200;
hight=200;
}
if (msg.isMe) {
_contentBtn.frame =CGRectMake(100, _msg.contentF.origin.y, width, hight);
}else{
_contentBtn.frame =CGRectMake(60, _msg.contentF.origin.y, width, hight);
}
svwebimage 加载图片取的大小为0,他是异步的,但可以显示,我本来用原图大小计算来设置frame,第一次加载时,在小为0 没办法相应点击时件,但图是显示的。第二次就有大小了,正常了
原文地址:http://www.cnblogs.com/anjsxz/p/3725066.html