當我更改其maximumValue屬性時,UISlider的擦洗沒有重新定位。我通過清理UISlider A來動態地改變UISlider B的maximumValue屬性。所以當UISlider A被改變爲例如1 UISlider B的maximumValue + = 1。 UISlider B應該自動更新其擦洗位置,但它不會。如果我然後按UISlider B擦洗它會得到更新。iPhone:UISlider動態更改maximumValue
這是什麼解決方案?
當我更改其maximumValue屬性時,UISlider的擦洗沒有重新定位。我通過清理UISlider A來動態地改變UISlider B的maximumValue屬性。所以當UISlider A被改變爲例如1 UISlider B的maximumValue + = 1。 UISlider B應該自動更新其擦洗位置,但它不會。如果我然後按UISlider B擦洗它會得到更新。iPhone:UISlider動態更改maximumValue
這是什麼解決方案?
如果你想改變滑塊的價值,你需要使用:
- (void)setValue:(float)value animated:(BOOL)animated
maximumValue只改變什麼的拇指可以代表
的上限值,我有這個確切的問題:當以編程方式設置maximumValue時,即使您顯式調用setValue,UISlider拇指也不會在軌道上重新定位。例如:
// Setup:
UISlider *a = [[UISlider alloc] init];
a.minimumValue = 1.00;
a.maximumValue = 100.00;
[a setValue: 50.00];
/* CORRECT: The thumb is in the centre of the track, at position "50.00":
1 ---------------------------() --------------------------- 100
a.value == 50
*/
// Set maximumValue programmatically:
[a setMaximumValue: 1000.00];
/* INCORRECT: The thumb is still in the centre of the track: position "500.00":
1 ---------------------------() --------------------------- 1000
a.value == 50
|<---- It should be here (!)
*/
// Call setValue explicitly, to no avail:
[a setValue: 50.00];
/* INCORRECT: The thumb is still in the centre of the track: position "500.00":
1 ---------------------------() --------------------------- 1000
a.value == 50
|<---- It should be here (!)
*/
我能夠解決這個問題是變化的UISlider的價值,這似乎迫使UISlider(的尋找一個解決方案在線,書籍和實驗小時後)的唯一途徑重繪。我不喜歡它,但它的工作原理:
[a setValue:a.value+1 animated:NO];
[a setValue:a.value-1 animated:NO];
/* (The thumb is now at position "50.00"):
1 --() ---------------------------------------------------- 1000
a.value == 50
*/
如果有人知道更好的方式來做到這一點,我很想了解它。 ( - :