嗨,大家好,我正在嘗試創建一個包含7個不同部分的滑塊,因爲您滑動滑塊時標籤會發生變化。iOS的編碼滑塊的問題
我已經將它與所有.m .h鏈接,所以標籤與滑塊等文件相互作用,但只有值爲0,0.5和1的那些似乎正在工作?
有人能指出我做錯了什麼的正確方向嗎? Im新的iOS開發,這是我第一次使用滑塊。
這是我在.m文件代碼滑塊
-(IBAction)slidetheslider:(id)sender; {
q4label1.text = [NSString stringWithFormat:@"%0.1f",question4slider.value];
if (question4slider.value == 0) {
q4label2.text = @"> 2.5 dots L";
}
if (question4slider.value == 0.2) {
q4label2.text = @" 2.5 dots L";
}
if (question4slider.value == 0.3) {
q4label2.text = @"1-2 dots L";
}
if (question4slider.value == 0.5) {
q4label2.text = @"< 1 dot L/R";
}
if (question4slider.value == 0.7) {
q4label2.text = @"1-2 dots R";
}
if (question4slider.value == 0.8) {
q4label2.text = @"2.5 dots R";
}
if (question4slider.value == 1) {
q4label2.text = @"> 2.5dots R";
}
}
也許這個[tutorial](http://www.techrepublic.com/blog/software-engineer/better-code-uislider-basics-for-apple-ios/)會幫助你。 – snowdragon