1

我正在下载一张知道图片网址的图片。现在我如何使用快速查看框架查看此图像。我正在使用以下代码下载。

UIImage *image = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL  
URLWithString:@"http://good-wallpapers.com/pictures/3048/frosty_apple_logo_iphone.jpg"]]];

如果我有一个 UIImages 的数组或字典,我应该怎么做才能快速查看呢?

4

1 回答 1

2

滚动视图中的 UIimageview 可以很好地显示所有图像。下面是将数组中的所有图像加载到 UIscrollview 中的 UIimageView

for (UIView *v in [scrollView subviews]) {
    [v removeFromSuperview];
}

CGRect workingFrame = scrollView.frame;
workingFrame.origin.x = 0;

for(id datavalue in tableList) {

    UIImage *downloadedImage = [UIImage imageWithData:datavalue];
    imageview = [[UIImageView alloc] initWithImage:downloadedImage];
    [imageview.layer setBorderColor: [[UIColor grayColor] CGColor]];
    [imageview.layer setBorderWidth: 2.0];
    [imageview setContentMode:UIViewContentModeScaleAspectFit];
    imageview.frame = workingFrame;
    [scrollView addSubview:imageview];
    [imageview release];

    workingFrame.origin.x = workingFrame.origin.x + workingFrame.size.width;
}

[scrollView setPagingEnabled:YES];
[scrollView setContentSize:CGSizeMake(workingFrame.origin.x, workingFrame.size.height)];

其中 tablelist 是图像数据的集合。

于 2012-06-22T09:48:01.613 回答