iosuiviewcontrollerios7uislider

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.


Solution

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