我想在一个图像视图中显示图像,当调用 IBAction 时,它会显示下一个图像。到目前为止,这是我的代码
- (void)viewDidLoad
{
[super viewDidLoad];
//init array with images what you have
images = [[NSArray alloc] initWithObjects:@"IMG_2605.JPG",@"IMG_2627.JPG",@"IMG_2597.JPG",@"IMG_2613.JPG",@"IMG_2596.JPG ",nil];
indexImage = 0;
}
-(IBAction)button1:(id)sender {
NSString *imageName = [images objectAtIndex:indexImage];
self.image1.image = [UIImage imageNamed:imageName];
self.image1.image = [images objectAtIndex:indexImage];
indexImage++;
NSLog(@"B = 1");
}