滚动视图中的 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 是图像数据的集合。