我想在ScrollView中添加3个URL中的3个图像,那我该怎么办? 请给我一个很好的教程或一些解释!将一些图像从一些URL添加到ScrollView中
0
A
回答
1
您可以使用“AsyncImageView”类文件来同步加载图像。
请参阅
https://stackoverflow.com/a/15377082/1713478
在这个答案这个方法调用的tableview您可以在滚动视图 使用循环和地点的ImageView为把图像垂直
int y = 10;
for (int i = 0; i < (number of images); i++)
{
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(X, y, width, height)];
NSString *imageURL = [NSString stringWithFormat: (image link for i number)];
AsyncImageView *async = [[AsyncImageView alloc]initWithFrame:CGRectMake(0, 0, width, height)];
[async loadImageFromURL:[NSURL URLWithString:imageURL]];
[imageView addSubview:async];
[scrollView addSubview:imageView];
y = y+height+10;
}
0
您可以通过用户PSTCollectionView对于gridView类型的显示和SDWebImage进行延迟加载。
0
你问如何加载远程图像或如何在滚动视图上布局它们?
1.
UIImage * image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"..."]]];
总结这一切在dispatch_async
或把它放在NSOperation
,以确保您没有阻止主线程。
2.
你可以尝试使用UIPageViewController
,而不是UIScrollView
这里查看我的回答:http://stackoverflow.com/questions/15151721/how-to-load-bundle-of-images-in -a-scrollview-with-horrizondal-scrolling-in-iphon/15155403#15155403 – Petar 2013-03-15 10:12:26