0
我不明白爲什麼這個代碼不工作iOS SDK - 更改UIPicker字體大小的問題。奇怪的行爲
我使用這個委託方法來調整字體(我不打擾顯示,由於其不相關)
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view;
這是一個多選擇器。我有三個組件。當我使用else運行帶有條件語句的代碼時,它使得部分0匹配部分2.我不能解釋這個
NSLog(@"%i", component); // only prints, 0, 1, 2
NSString *theString = @"";
if(component == 0){
theString = [_phosType objectAtIndex:row];
}
if(component == 1){
theString = [_quantity objectAtIndex:row];
} else { // THIS CAUSES PROBLEMS.
theString = [_units objectAtIndex:row];
}
pickerViewLabel.text = theString;
這個工作..什麼給!
NSLog(@"%i", component); // only prints, 0, 1, 2
NSString *theString = @"";
if(component == 0){
theString = [_phosType objectAtIndex:row];
}
if(component == 1){
theString = [_quantity objectAtIndex:row];
}
if(component == 2){ // THIS WORKS! BUT WHY?!
theString = [_units objectAtIndex:row];
}
pickerViewLabel.text = theString;
爲什麼我需要明確詢問組件是否是2?我可以看到當我NSLog組件,它永遠不等於0 1或2以外的任何東西。我在代碼中的其他地方使用'其他',並有問題。任何人都可以解釋嗎?
這是當你編寫過深夜發生了什麼 – hamobi