2011-08-10 67 views
0

我試圖在一個uiimageview中一個接一個顯示多個圖像。但它顯示最後的圖像。在一個uiimageview中顯示多個圖像

NSFileManager *fileManager = [NSFileManager defaultManager]; 
[scrollView addSubview:image]; 
[scrollView bringSubviewToFront:image]; 

for (int i = 0; i < [fileArr count]; i++) { 

NSArray *fileNameArr = [[fileArr objectAtIndex:i] componentsSeparatedByString:@"."]; 

if (![[fileNameArr lastObject] isEqualToString:@"cfg"]) { 

     check=line; 
     NSString *msg = [textView.text stringByAppendingString:[NSString stringWithFormat:@"Opening image: %@\n",[fileArr objectAtIndex:i]]]; 

     [textView performSelectorOnMainThread:@selector(setText:) withObject:msg waitUntilDone:NO]; 

     line=line+1; 

//specify the image path, open the image file with UIImage library 
NSString *imagePath = [NSString stringWithFormat:@"%@/%@",jfm,[fileArr objectAtIndex:i]]; 
     NSString *imageFile = [NSHomeDirectory() stringByAppendingPathComponent:imagePath]; 
     NSLog(@"----------------------------"); 
     NSLog(@"ImageFile: %@\n",imageFile); 
     NSLog(@"Interger value: %i\n",i); 

     UIImage *myImage = [UIImage imageWithContentsOfFile:imageFile]; 

     NSLog(@"Image Width: %f", myImage.size.width); 
     NSLog(@"Image height: %f", myImage.size.height); 

     //if image failed to open 
     if (myImage == nil) { 
        ... 
        ... 
        } 
      else{ 
      //[image setImage:myImage]; 
      image.image = myImage; 
      [NSThread sleepForTimeInterval:7]; 
    } 
      [image release]; 
      line=line+1; 
      [pool release]; 
} 
+0

也許這[教程](http://iphonenativeapp.blogspot.com/2011/03/how-to-show-animation-in-iphoneipad-app.html)與您的問題類似。你需要使用動畫來逐個顯示所有的圖像。 – mayuur

+0

我還需要逐個檢查數組中圖像的信息。如果我使用動畫,我怎樣才能單獨檢查圖像的信息? – Carissa

+0

什麼樣的信息? – mayuur

回答

0

您可能想要將它們作爲子視圖(其他圖像)添加到UIVIew:addSubView中。不過,我不積極,這是你的要求。