我已使用AsyncImageView
从网址加载图片。但图像未加载到图像视图宽度。以下是我的代码。
{
AsyncImageView *asyImage;
asyImage = [[AsyncImageView alloc] initWithFrame:frame];
[asyImage loadImageFromURL:[NSURL URLWithString:url]];
[propertyImage addSubview:asyImage];
propertyImage.contentMode = UIViewContentModeScaleAspectFit;
}
答案 0 :(得分:1)
NSString * urlString = @"http://img-paragon.sandicor.com/ParagonImages/Property/Q1/SANDICOR/150016147/0/0/0/729a48630a22f4436d3e45e671bb3548/1/e2d30ecd1633ebc3b6b1f6acbcc77331/150016147.JPG";
NSData *dataCoverImg = [NSData dataWithContentsOfURL:[NSURL URLWithString:urlString]];
UIImage *imgLocation = [UIImage imageWithData:dataCoverImg];
self.image = [imgLocation resizedImage:self.propertyImage.frame.size interpolationQuality:kCGInterpolationMedium]; // Can we resize image using UIImage+Resize equel to imageview size
self.urlForTesting=[NSURL URLWithString:urlString];
CGRect frame = self.propertyImage.bounds; AsyncImageView *asyImage;
asyImage=[[AsyncImageView alloc] initWithFrame:frame];
asyImage.imageURL =self.urlForTesting;
asyImage.layer.borderWidth = 2.0f;
asyImage.contentMode = UIViewContentModeScaleToFill;
asyImage.layer.masksToBounds=YES;
[self.propertyImage addSubview:asyImage];
self.mySecondImageView.image = self.image; // set directly to asyncimage view with aspect mode AspectFill
self.myThirdImageView.image = self.image; //Set to normal Image view with aspect Mode ScaleToFill
// Do any additional setup after loading the view, typically from a nib.
在这段代码中,我使用了三个图像视图样本,根据图像视图大小,所有这些样本都可以获得完整图像