cyclingIsBetter
cyclingIsBetter

Reputation: 17591

iOS: change subview with segmented control

I have four subview and when I select (segment ==1) in segmented control other view must have alpha at 0.00 and only subview number 1 must have alpha at 1.00, I show my code:

if (segmentedContr.selectedSegmentIndex == 1) {

    [subView1 setAlpha:0.0];

      }

it's simple, but where I must write this code? In an IBAction? or in a generic method (void)? If I do

-(void)segmentAction:(id)sender

where I must call this method?

Upvotes: 1

Views: 2504

Answers (1)

EmptyStack
EmptyStack

Reputation: 51374

You don't have to call that method explicitly from anywhere.

That method will be called automatically when you select a segment in the segmented control. And, make sure you have set the target and action for the segmented control.

[segmentedContr addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];

Upvotes: 1

Related Questions