2011-08-10 39 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中。不过,我不积极,这是你的要求。