UISlider iPhone SDK Question
Okay. In Xcode, I want my application to run a line of code once the UISli开发者_开发问答der gets to 1.00 or the end of the slider. How would I do this?
Add these to your UIViewController.
In your .h, below the interface:
-(IBAction)sliderChangedValue:(id) sender;
In your .m:
-(IBAction)sliderChangedValue:(id) sender {
if([sender isKindOfClass:[UISlider class]]) {
UISlider *slider = (UISlider *)sender;
if(slider.value == 0.0 || slider.value == 1.0) {
//your line of code
}
}
}
Then in Interface Builder connect Value Changed of your UISlider to this method.
Write an IBAction method, and connect it to your UISlider in Interface Builder, selecting "On Changed Value" in the dialog that will appear. Then add some code like this to the method:
if(mySlider.value == 1.0f){
//Insert your code here
}
--James
精彩评论