I want to add 3 images from 3 URLs in ScrollView so how could I do? Please give me a good tutorial or some explanations!
Asked
Active
Viewed 1,274 times
0
-
Check my answer here: http://stackoverflow.com/questions/15151721/how-to-load-bundle-of-images-in-a-scrollview-with-horrizondal-scrolling-in-iphon/15155403#15155403 – Petar Mar 15 '13 at 10:12
3 Answers
1
You can use "AsyncImageView" class files it will load image synchronically.
please refer
https://stackoverflow.com/a/15377082/1713478
in this answer this method call for tableview you can use in for loop and place imageview in scrollview for putting images vertically
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;
}
-
-
use for loop and use code from "UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(X, y, width, height)];" – Pratik Mar 15 '13 at 05:03
-
-
why use AsyncImageView in ScrollView ? it load only one time,if we use cell means it load more? – NANNAV Mar 15 '13 at 05:13
-
Please explain clearly about what is (image link for i number) of your code? – Sovannarith Mar 15 '13 at 07:08
-
this is image link of your image if i = 0 then first image link and i=1 then second image link. – Pratik Mar 15 '13 at 07:12
-
when i clean memory, cache will be also clear i dont want to clear cache how can i do it. – sohan vanani Nov 18 '15 at 07:42
0
You can user PSTCollectionView for gridView kind of display and SDWebImage for lazy loading.

Yashesh
- 1,799
- 1
- 11
- 29
0
Are you asking how to load remote images OR how to layout them on a scroll view?
1.
UIImage * image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"..."]]];
Wrap it all in dispatch_async
or put it in NSOperation
to make sure you don't block the main thread.
2.
You can try to use UIPageViewController
instead of a UIScrollView

Yariv Nissim
- 13,273
- 1
- 38
- 44