Q:

how to change image in imageView on button click

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; 
    }
}

A:

Try this format - modelImagewView.image = [UIImage imageNamed:@"composittwo.jpg"];
Also, make sure you have set tag numbers properly so that selectedIndex is not always 0. At the same time check if you have linked this IBAction to the appropriate button.

