我的應用程序在幾個不同的視圖中使用UIStepper控件。我發佈了一個應用程序的小更新,根本不應該影響這些視圖,並且我開始得到報告,現在應用程序中的所有UISteppers都被禁用了。一位用戶發送了一個屏幕快照,並且步進控制器顯示爲其啓用的屬性設置爲「否」。但是,在我的代碼中沒有任何地方可以設置該屬性,而默認值爲YES。我在應用程序中搜索了「啓用」一詞的實例,以確保我不會意外地禁用它,而我不是。我的iOS應用程序中的所有UISteppers已被禁用
我想也許是enabled屬性的iOS版本之間改變了默認值,但誰報告這個用戶運行iOS 5.1.1,同我的開發設備。我只是開始聽說這個應用程序更新的問題。
除了設置啓用的屬性,我發現,如果最小值和最大值設置爲同一值的步進電機將被禁用。我很確定這不會發生在我的應用程序中。這些值是硬編碼的,並傳遞給設置方法,並且自從許多應用程序版本以前,我沒有更改過這些代碼。
你知道爲什麼會發生這種情況嗎?我自己無法再現問題,並且僅影響某些用戶,因此很難排除故障。
這裏是我創建的UISteppers,對於它的價值代碼:
- (UIStepper *)makeStepperInput:(float)currentValue minValue:(float)minValue maxValue:(float)maxValue increment:(float)increment {
int stepperWidth = 94;
int stepperHeight = 27;
CGRect stepperFrame = CGRectMake(0, 0, stepperWidth, stepperHeight);
UIStepper *stepperInput = [[[UIStepper alloc] initWithFrame:stepperFrame] autorelease];
stepperInput.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
[stepperInput setValue:currentValue];
[stepperInput setMinimumValue:minValue];
[stepperInput setMaximumValue:maxValue];
[stepperInput setStepValue:stepValue];
[stepperInput setContinuous:NO];
NSLog(@"making stepper with values %f, %f, %f, %f (%i)", currentValue, minValue, maxValue, stepValue, stepperInput.enabled);
[stepperInput addTarget:self action:@selector(onChange:) forControlEvents:UIControlEventValueChanged];
return stepperInput;
}
更新:我有誰願意安裝與上述的NSLog線調試版本的用戶。他向我發送了控制檯輸出,它顯示了步進器的最小值和最大值是正確的(在一種情況下爲1和20),並且啓用的屬性爲YES。不幸的是,消除我的兩個理論關於什麼可以在這裏發生的事情......