Ios Iphone上的幻灯片放映和过渡?

Ios Iphone上的幻灯片放映和过渡?,ios,xcode,slideshow,transition,Ios,Xcode,Slideshow,Transition,我有以下代码的有线问题 如果我使用这些代码并在模拟器上运行它,他只会向我显示带有转换的数组中的前两张图片。如果我在Iphone上运行它,他只会给我看第一张图片。 他也不会重复这些图片 我做错了什么 - (void)viewDidLoad{ [super viewDidLoad]; welcomePhoto = [NSArray arrayWithObjects:@"Bild.jpeg",@"Bild1.jpeg", @"Bild2.png", nil]; ima

我有以下代码的有线问题

如果我使用这些代码并在模拟器上运行它,他只会向我显示带有转换的数组中的前两张图片。如果我在Iphone上运行它,他只会给我看第一张图片。 他也不会重复这些图片

我做错了什么

    - (void)viewDidLoad{
    [super viewDidLoad];

    welcomePhoto = [NSArray arrayWithObjects:@"Bild.jpeg",@"Bild1.jpeg", @"Bild2.png", nil];
    imageView.image = [UIImage imageNamed:[welcomePhoto objectAtIndex:0]];
    [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(transitionPhotos) userInfo:nil repeats:YES];
}


-(void)transitionPhotos{
    int photoCount;
    if (photoCount < [welcomePhoto count] - 1){
        photoCount ++;
    }else{
        photoCount = 0;
    }
    [UIView transitionWithView:self.imageView
                      duration:2.0
                       options:UIViewAnimationOptionTransitionCrossDissolve
                    animations:^{ imageView.image = [UIImage imageNamed:[welcomePhoto objectAtIndex:photoCount]]; }
                    completion:NULL];    
}
-(void)viewDidLoad{
[超级视图下载];
welcomePhoto=[NSArray阵列,其对象为:@“Bild.jpeg”,“Bild1.jpeg”,“Bild2.png”,无];
imageView.image=[UIImage ImageName:[welcomePhoto objectAtIndex:0]];
[NSTimer scheduledTimerWithTimeInterval:3.0目标:自选择器:@selector(transitionPhotos)userInfo:nil repeats:YES];
}
-(无效)过渡照片{
国际光电计数;
if(光电计数<[Welcome光电计数]-1){
光电计数++;
}否则{
光电计数=0;
}
[UIView转换WithView:self.imageView
持续时间:2.0
选项:UIViewAnimationOptionTransitionCrossSolve
动画:^{imageView.image=[UIImage ImageName:[welcomePhoto objectAtIndex:photoCount]];}
完成:空];
}

尝试将此添加到viewDidLoad中

UIImageView* animatedImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 90, 100, 100)];
[self.view addSubview:animatedImageView];
animatedImageView.animationImages = [NSArray arrayWithObjects:    
                                     [UIImage imageNamed:@"bild.png"],
                                     [UIImage imageNamed:@"bild.png"],
                                     [UIImage imageNamed:@"bild.png"], nil]; //etc
animatedImageView.animationDuration = 3.0f * [animatedImageView.animationImages count];
animatedImageView.animationRepeatCount = 0;
[animatedImageView startAnimating];
[self.view addSubview: animatedImageView];

我找到了。你应该跳过初始化transitionPhotos中的photoCount。将其设置为iVar或属性。

尝试此代码

    NSArray *imagesArray;
 int photoCount;
 UIImageView *imageView;
-(void)setupImageView{
     photoCount = 0;
     [[NSArray alloc]initWithObjects:[UIImage imageNamed:@"imgA.png"] ,[UIImage imageNamed:@"imgB.png"] ,[UIImage imageNamed:@"imgC.png"] ,[UIImage imageNamed:@"imgD.png"] ,[UIImage imageNamed:@"imgE.png"] , nil];         imageView =[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, width, height)];
     imageView.image = [imagesArray objectAtIndex:photoCount];
     [self.view addSubview:imageView];
     [NSTimer scheduledTimerWithTimeInterval:20.0 target:self selector:@selector(transitionPhotos) userInfo:nil repeats:YES];

 }

 -(void)transitionPhotos{


if (photoCount < [imagesArray count] - 1){
    photoCount ++;
}else{
    photoCount = 0;
}
[UIView transitionWithView:self.imageView1
                  duration:2.0
                   options:UIViewAnimationOptionTransitionCrossDissolve
                animations:^{ imageView.image = [imagesArray objectAtIndex:photoCount]; }
                completion:NULL];    
}
NSArray*imagesArray;
国际光电计数;
UIImageView*图像视图;
-(无效)setupImageView{
光电计数=0;
[[NSArray alloc]initWithObjects:[UIImage ImageName:@“imgA.png”]、[UIImage ImageName:@“imgB.png”]、[UIImage ImageName:@“imgC.png”]、[UIImage ImageName:@“imgD.png”]、[UIImage ImageName:@“imgE.png”]、nil];imageView=[UIImageView alloc]initWithFrame:cRectmake(0,0,宽度,高度)];
imageView.image=[imagesArray objectAtIndex:photoCount];
[self.view addSubview:imageView];
[NSTimer scheduledTimerWithTimeInterval:20.0目标:自选择器:@selector(transitionPhotos)userInfo:nil repeats:YES];
}
-(无效)过渡照片{
if(光电计数<[imagesArray计数]-1){
光电计数++;
}否则{
光电计数=0;
}
[UIView transitionWithView:self.imageView1
持续时间:2.0
选项:UIViewAnimationOptionTransitionCrossSolve
动画:^{imageView.image=[imagesArray objectAtIndex:photoCount];}
完成:空];
}

您是否尝试过使用调试器单步执行代码?thx您的代码正在运行。如何将转换添加到代码中?有没有其他办法像我一样?