开发者

Display multiple images in one uiimageview

开发者 https://www.devze.com 2023-03-27 03:56 出处:网络
I am trying to display multiple images in one uiimageview, one by one. But it onyly display the last image.

I am trying to display multiple images in one uiimageview, one by one. But it onyly display the last image.

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

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

NSArra开发者_C百科y *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];
}


You may want to just add them as subviews (the other images) with UIVIew:addSubView. However I'm not positive that's what your looking for.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号