2012-07-05 41 views
0

我是iPhone的初学者。我已在阵列中,我有过的所有图像,但图像当我点击下一步按钮不会显示..如何在单击下一个按钮时逐个显示图像?

我的代码是

images= [[NSArray arrayWithObjects: 
         [UIImage imageNamed:@"1.png"], 
         [UIImage imageNamed:@"2.png"], 
         [UIImage imageNamed:@"3.png"], 
         [UIImage imageNamed:@"4.png"], 
         nil] retain]; 
-(IBAction)Next 
{ 

    currentImage++; 
    if(currentImage +1>=[images count]) 
    { 
     currentImage=0; 
     NSLog(@"print:%@",currentImage); 
     UIImage *img=[images objectAtIndex:currentImage]; 
     [animalphoto setImage:img]; 


    } 
    else 
    { 
     currentImage++; 
     NSLog(@"hello:%@",currentImage); 



    } 
} 

但单击下一步按钮,往往时间按钮图像不显示时间经常所以给出任何建议和源代码

+0

你的代码后,当currentImage指数计数器将只显示一个新的形象高于计数以显示图像a换句话说,t指数为0;逻辑是不正确的。当计数器等于计数值时,你应该只将计数器重置为0,并用新索引显示新图像。 – 2012-07-05 12:58:24

+0

什么是'currentImage'?你正在改变它,就好像它是一个数字,但把它作为一个对象打印出来。 – 2012-07-05 13:00:37

回答

0

只是把if语句的两行的NSLog的其他部分还那么这个问题就解决了

相关问题