UISlider
のvalue
が変更されると、メソッドが呼び出されますか? UISliders
値に基づいて値を更新できるようにしたいのですが、変更された場合にのみ...
助けてくれてありがとう。
Swift 3
//There is your slider
@IBOutlet weak var mSlider: UISlider!
//add a target on your slider on your viewDidLoad for example
self.mSlider.addTarget(self, action: #selector(MyClass.onLuminosityChange), for: UIControlEvents.valueChanged)
//callback called when value change
func onLuminosityChange(){
let value = self.mSlider.value
}
ViewController.h
@property (strong, nonatomic) IBOutlet UIProgressView *prgs;
- (IBAction)slider:(id)sender;
@property (strong, nonatomic) IBOutlet UISlider *slider1;
@property (strong, nonatomic) IBOutlet UILabel *lbl;
ViewController.m
- (IBAction)slider:(id)sender
{
self.prgs.progress=self.slider1.value;
self.lbl.text = [NSString stringWithFormat:@"%f",
self.slider1.value];
}