NSArray *imageArray;
int imageArrayIndex;
- (void)viewDidLoad
{
[super viewDidLoad];
imageArray = [[NSArray alloc] initWithObjects:
[UIImage imageNamed:@"yourpic1.png"],
[UIImage imageNamed:@"yourpic2.png"],
[UIImage imageNamed:@"yourpic3.png"],
nil];
imageArrayIndex = 0;
}
- (IBAction)right {
imageArrayIndex++;
if (imageArrayIndex == imageArray.count) {
imageArrayIndex = 0;
}
images.image = [imageArray objectAtIndex:imageArrayIndex];
}
- (IBAction)left {
imageArrayIndex--;
if (imageArrayIndex == -1) {
imageArrayIndex = imageArray.count - 1;
}
images.image = [imageArray objectAtIndex:imageArrayIndex];
}