views:

105

answers:

3

I have a view with a UINavBar in it, and a scrollview beneath that. The nav bar has a segmented button which I want to use to toggle between 2 images to be presented in the scrollview. Both of the images are in the same scrollview but one is hidden to start.

I was trying to do this like so:

-(IBAction)segmentedControlIndexChanged{
switch (self.segmentedControl.selectedSegmentIndex)
{
    case 0:
        bvpiimg.hidden = NO;
        mppiimg.hidden = YES;
    case 1:
        bvpiimg.hidden = YES;
        mppiimg.hidden = NO;
        break;
    default:
        break;
}

}

It isn't doing anything when I switch the segmented control though.. Also, these images are HUGE pngs.. Is there a better way than show/hide that would be easier on the memory/performance.

A: 

Make sure the segmented control's action is hooked up to the method in IB.

Avalanchis
A: 

you need a break after case 0: if this is a direct copy. also the break after case 1 isn't necessary here.

Jesse Naugher
A: 

I got it! The problem was my I had the seg control set to "touch up inside" when it needed to be "value change"

Hippocrates