Note that there are some explanatory texts on larger screens.

plurals
  1. POcannot display UIImage one after one
    text
    copied!<p>I'm kind of stuck since this morning... i'm trying to load an image after another image but... it doesnt work... i don't even have my first image displayed ...</p> <p>There is my code : </p> <pre><code>- (void) checkResources { NSString *bundleRoot = [[NSBundle mainBundle] bundlePath]; NSFileManager *manager = [NSFileManager defaultManager]; NSDirectoryEnumerator *direnum = [manager enumeratorAtPath:bundleRoot]; NSString *cuttedName; NSString *cuttedName1; for (NSString *path in direnum) { if ([[path pathExtension] isEqualToString:@"mp4"]) { cuttedName1 = [path stringByReplacingOccurrencesOfString:@"ressources/" withString:@""]; cuttedName = [cuttedName1 stringByReplacingOccurrencesOfString:@".mp4" withString:@""]; if ([cuttedName isEqualToString:[NSString stringWithFormat:@"%d", num]]) { NSString *media = [NSString stringWithFormat:@"%@/%@", bundleRoot, path]; [self startSlideShow:media]; } } else if ([[path pathExtension] isEqualToString:@"mov"]) { cuttedName1 = [path stringByReplacingOccurrencesOfString:@"ressources/" withString:@""]; cuttedName = [cuttedName1 stringByReplacingOccurrencesOfString:@".mov" withString:@""]; if ([cuttedName isEqualToString:[NSString stringWithFormat:@"%d", num]]) { NSString *media = [NSString stringWithFormat:@"%@/%@", bundleRoot, path]; [self startSlideShow:media]; } } else if ([[path pathExtension] isEqualToString:@"png"]) { cuttedName1 = [path stringByReplacingOccurrencesOfString:@"ressources/" withString:@""]; cuttedName = [cuttedName1 stringByReplacingOccurrencesOfString:@".png" withString:@""]; if ([cuttedName isEqualToString:[NSString stringWithFormat:@"%d", num]]) { NSString *media = [NSString stringWithFormat:@"%@/%@", bundleRoot, path]; num++; [self startImage:media]; } } } } - (void) startImage:(NSString *)nameFile { CGRect myImageRect = CGRectMake(0, 0, 200, 500); UIImageView *imageView; imageView = [[UIImageView alloc] initWithFrame:myImageRect]; [imageView setImage:[UIImage imageNamed:@"0.png"]]; NSLog(@"IAMGE %@", imageView.image); [self.view addSubview:imageView]; [self performSelector:@selector(checkResources) withObject:nil afterDelay:10]; // this will give time for UI to update itself.. [imageView release]; } - (void) startSlideShow:(NSString *)nameFile { NSURL *url = [NSURL fileURLWithPath:nameFile];//[[NSBundle mainBundle] pathForResource:@"2" ofType:@"mov"]]; MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url]; // NSLog(@" URL : %@", url); [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer]; moviePlayer.view.frame = CGRectMake(0, 0, 500, 600); moviePlayer.controlStyle = MPMovieControlStyleDefault; moviePlayer.shouldAutoplay = YES; [self.view addSubview:moviePlayer.view]; [moviePlayer setFullscreen:YES animated:YES]; } -(void)moviePlayBackDidFinish: (NSNotification*)notification { MPMoviePlayerController *moviePlayer = [notification object]; [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer]; if ([moviePlayer respondsToSelector:@selector(setFullscreen:animated:)]) { // [moviePlayer.view removeFromSuperview]; } //[[moviePlayer release] addAnimation:animation forKey:kCATransition]; num++; [self checkResources]; } </code></pre> <p>Don't mind about the goal of my code :) i just want to display the uiimage, then when the method checkResources is called after displayed the first image i will send to startImage another image. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload