2013-03-15 56 views
0

我想在ScrollView中添加3個URL中的3個圖像,那我該怎麼辦? 請給我一個很好的教程或一些解釋!將一些圖像從一些URL添加到ScrollView中

+0

這裏查看我的回答: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

回答

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

它如何用於ScrollView? – NANNAV 2013-03-15 05:02:23

+0

用於循環並使用「UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(X,y,width,height)];」 – Pratik 2013-03-15 05:03:57

+0

to [cell addSubview:imageView];並且將單元格​​替換爲滾動視圖 – Pratik 2013-03-15 05:04:45

0

你問如何加載遠程圖像或如何在滾動視圖上佈局它們?

1.
UIImage * image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"..."]]];
總結這一切在dispatch_async或把它放在NSOperation,以確保您沒有阻止主線程。

2.
你可以嘗試使用UIPageViewController,而不是UIScrollView

相關問題