开发者

segmented control to switch images in scrollview iphone

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.


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


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜