我试图在一个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 :(得分:0)
您可能只想使用UIVIew:addSubView将它们添加为子视图(其他图像)。但是,我并不认为这是你想要的。