Slideshow with multiple images needing a previous image button.
I want this button to be able to display the previous image that was shown
This is the code for the 'next' button:
-(IBAction)nextbutton: (id)sender;
{
int ptr = rand() % 6;
NSArray *images = [[NSArray alloc] initWithObjects:@"Americans.png",@"Approach.png",@ "Arianny.png",@"Atoms.png",@"Australia.png",@"Aver age.png",nil];
}
This is the code i am having trouble with I want this button to show the image that was shown previously. from the array randomized above but it doesnt do that:
-(IBAction)previousbutton: (id)sender;
{
int ptr=0;
if (ptr <=5)
{
ptr = 5;
ptr--;
[imageView setImage:[images objectAtIndex: ptr]];
}
NSArray *images = [[NSArray alloc] initWithObjects:@"Americans.png",@"Approach.png",@ "Arianny.png",@"Atoms.png",@"Australia.png ",@"Average.png",nil];
[imageView setImage:[UIImage imageNamed:[images objectAtIndex: ptr]]];
}
|