我认为没有返回 UISlider 值的好方法。
首先,正如 Abdullah Shafique 所说,您需要以编程方式为 UISLider 创建方法,例如:
[yourSlider addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
然后,您可能必须在选择数字后调用所需的方法,例如:
- (void)valueChanged:(id)sender {
UISlider *slider = (UISlider *)sender;
int value = slider.value;
[self shootMissles:value]; //This line will send the value of slider to the method below.
}
我对 INPUT 和 APPLE BASIC 不熟悉,但是 [self shootMissles:value] 行会将滑块值传递给您可以随心所欲地做任何事情的方法。例如:
- (void)shootMissles:(float)numOfMissles {
//code to shoot x number of missles based on UISlider value - be mindful
//that UISlider spits out float values, you will have to round to get whole numbers.
}