2016-01-12 25 views
0

這裏的問題是我得到從服務器鏡像的數組的數組,但我不能夠對ImageView。下面的代碼顯示的圖像,圖片上的圖像

for (int i=0; i<=images.count; i++) { 

      images= [NSMutableArray arrayWithObjects:@"logo.png",@"logo.png",@"logo.png",@"logo.png",@"logo.png",@"logo.png",@"logo.png",@"logo.png",@"logo.png",@"logo.png", nil]; 

      [imgView setImage:[UIImage imageNamed:[images objectAtIndex:i]]]; 

    } 

能否請您幫助我如何顯示圖像。謝謝。

+0

圖像存儲在哪裏?和imageView是一個還是很多? –

+0

你存儲圖像? –

+0

只有一個imageView,我從服務器端獲取圖像數組@the_UB –

回答

3

做到這一點,看看會發生什麼:

images= [NSMutableArray arrayWithObjects:@"logo.png",@"logo.png",@"logo.png",@"logo.png",@"logo.png",@"logo.png",@"logo.png",@"logo.png",@"logo.png",@"logo.png", nil]; 

for (int i=0; i<=images.count; i++) { 
     [imgView setImage:[UIImage imageNamed:[images objectAtIndex:i]]]; 
} 

編輯:

首先,您使用的將不顯示任何圖像,因爲所有圖像都存儲在服務器端的代碼。要檢索這些圖像,您需要Get image through url

其次,要顯示滑塊圖像,您必須使用Page View Controller或查看此鏈接:How to create image slider in iOS?

0

你在哪裏存儲圖像?這僅適用於圖像存儲在包中的情況。如果圖像首先出現在服務器中,則需要從服務器獲取圖像的確切URL(例如,它類似於http://www.w3schools.com/images/w3schools_green.jpg),然後使用以下代碼

[imgView setImage:[UIImage imageWithContentsOfURL:[NSURL URLWithString:[images objectAtIndex:i]]]];