I want to change the image in image view on button click but it does not changing. I am using JPG image to load in image View
- (IBAction) changeImage:(id)sender
{
UIButton *tappedButton = (UIButton*) sender;
NSInteger selectedIndex = [tappedButton tag];
if (selectedIndex==0)
{
UIImage *modelimage = [UIImage imageNamed:@"compositone.jpg"];
modelImagewView.image=modelimage;
}
else
{
UIImage *modelimage = [UIImage imageNamed:@"composittwo.jpg"];
modelImagewView.image=modelimage;
}
}
Try this format –
modelImagewView.image = [UIImage imageNamed:@"composittwo.jpg"];Also, make sure you have set
tagnumbers properly so thatselectedIndexis not always 0. At the same time check if you have linked thisIBActionto the appropriate button.