Mac_Play
Mac_Play

Reputation: 302

UISlider action - iOS

Hi, I am working in my first app. I want set action for each Slider values. For eg: slider value 3 and clicking the next button go to some view controller, if value 4 goes to some other controller.

- (IBAction)controlValueChanged:(id)sender
{
    if (self.sliders.value== 3) 
    {
        NSLog(@"value is 3");
        CGRect rect = CGRectMake(90, 90, 35, 35);
        UILabel *label= [[UILabel alloc]initWithFrame:rect];
        label.text = @"Hi Man";
        [self.view addSubview:label];
    }
}

It's not working with above code. please help.

Upvotes: 0

Views: 187

Answers (2)

Xhacker Liu
Xhacker Liu

Reputation: 1618

You may want to check if controlValueChanged: is correctly invoked. Add something like NSLog(@"value is %f", [sender value]); in that method.

Upvotes: 0

malex
malex

Reputation: 10096

You need to check the value of the sender

UISlider *slider = (UISlider*)sender;
If (slider.value == 3)

Upvotes: 0

Related Questions