You may want to check if controlValueChanged:
is correctly invoked. Add something like NSLog(@"value is %f", [sender value]);
in that method.
UISlider action - iOS
-
29-09-2022 - |
質問
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.
解決
他のヒント
You need to check the value of the sender
UISlider *slider = (UISlider*)sender;
If (slider.value == 3)
所属していません StackOverflow