0
可能重複:
How to display images from an xml file in UI Image View如何在UI圖像視圖顯示從XML文件中的圖像
我有一個XML文件,也有子類別的圖像的數量,我想 要在「圖像視圖」中顯示所有圖像,並且「圖像視圖」將在滾動視圖中滾動視圖,因爲您需要繼續加載圖像。我是 編碼有困難。下面的代碼給了我url 鏈接,但我很難在'圖像 視圖'上顯示圖像,該圖像可以使用「ScrollView」滾動。我還在顯示 xml文件,其中顯示產品
/////// XML文件////
<product>
<product_name>HRC Classic Pin Collector Bag Blk – Hard Rock</product_name>
<url>http://rockshop.hardrock.com/PinsCollectibles/Pins/Product/HRC Classic Pin Collector Bag Blk/?src=sli</url>
<image>http://rockshop.hardrock.com/ProductImages/HRC Classic Pin Collector Bag Blk.1.jpg?w=177</image>
<large_image>http://rockshop.hardrock.com/ProductImages/HRC Classic Pin Collector Bag Blk.1.jpg?w=350</large_image>
<front_image>http://rockshop.hardrock.com/ProductImages/HRC Classic Pin Collector Bag Blk.1.jpg?w=80</front_image>
<product_number>HRC Classic Pin Collector Bag Blk</product_number>
<availability>1</availability>
<long_des>HRC Classic Pin Collector Bag Blk</long_des>
<launch_date>4/15/2011 10:49:54 AM</launch_date>
<price>40</price>
<category>Pins & Collectibles</category>
<sub_category>Pins</sub_category>
</product>
這裏是代碼
-(IBAction)downloadImages:(id)sender
{
NSData *data = [NSData dataWithContentsOfFile:@"pathOfURL"];
NSError *error = nil;
GDataXMLDocument *document = [[GDataXMLDocument alloc] initWithData:data options:0 error:&error];
NSError *err=nil;
NSArray *nodes = [document nodesForXPath:@"/product_list/product[category = \"Pins & Collectibles\"]/image" error:&err];
NSMutableArray *array =[[NSMutableArray alloc]initWithCapacity:[nodes count]];
for(int i=0;i<[nodes count]; i++)
{
[array addObject:(NSString *)[[(NSString *)[[(NSString *)[[[NSString stringWithFormat:@"%@",[nodes objectAtIndex:i]] componentsSeparatedByString:@"{"] objectAtIndex:1] componentsSeparatedByString:@"<image>"] objectAtIndex:1] componentsSeparatedByString:@"</image>"] objectAtIndex:0] ];
}
NSLog(@"%@",array);
}
NSLog(@「%@」,array);它顯示在輸出 控制檯中的所有圖像url我只需要顯示它們在UIImage中的筆尖文件,我不是 能夠做到這一點,所以當你點擊一個按鈕時,所有的圖像應該在滾動視圖中顯示 。
在這個問題中有更多的細節,但你應該編輯原來的。 – jrturton