Я немного застрял с этого утра ... Я пытаюсь загрузить изображение за другим, но ... оно не работает ... У меня даже не отображается мое первое изображение ...
Вот мой код:
- (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];
}
Не обращайте внимания на цель моего кода :) Я просто хочу отобразить uiimage, тогда когда вызывается метод checkResources после отображения первогоизображение, которое я пошлю, чтобы начать изображение другого изображения.