Try this to show images on imagesView....
UIImageView *imageView;
NSArray *arrayOfImage=[[NSArray alloc]initWithObjects:@"i1.jpg",@"i2.jpg",@"i3.png", nil];;
float x=10;
float y=50;
float width=100;
float height=100;
int i=0;
for(i=0;i<[arrayOfImage count];i++)
{
imageView=[[UIImageView alloc]initWithFrame:CGRectMake(x+width*i, y, width, height)];
imageView.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@",[arrayOfImage objectAtIndex:i]]];
[self.view addSubview:imageView];
}
else if(i==[arrayOfImage count])
{
i=0;
imageView.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@",[arrayOfImage objectAtIndex:i]]];
[self.view addSubview:imageView];
i++;
}
if you want to change the I'm image on next button and back button... then try below code
- (IBAction)btnClicked:(id)sender
{
UIImageView *imageView;
NSArray *arrayOfImage=[[NSArray alloc]initWithObjects:@"i1.jpg",@"i2.jpg",@"i3.png",@"i1.jpg",@"i2.jpg",@"i3.png", nil];;
float x=100;
float y=100;
float width=100;
float height=100;
imageView=[[UIImageView alloc]initWithFrame:CGRectMake(x, y, width, height)];
if([sender tag]==0)
{
if(i<[arrayOfImage count])
{
imageView.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@",[arrayOfImage objectAtIndex:i]]];
[self.view addSubview:imageView];
i++;
}
else if(i==[arrayOfImage count])
{
i=0;
imageView.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@",[arrayOfImage objectAtIndex:i]]];
[self.view addSubview:imageView];
i++;
}
}else
{
if(i<[arrayOfImage count])
{
imageView.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@",[arrayOfImage objectAtIndex:i]]];
[self.view addSubview:imageView];
i--;
}
else if(i==-1)
{
i=0;
imageView.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@",[arrayOfImage objectAtIndex:i]]];
[self.view addSubview:imageView];
i++;
}
}
}
Note: set Tag to Next button as 0 and set tag to back button as 1.