0
根據文檔,選擇器視圖傾向於使用attributedTitleForRow
而不是titleForRow
。如果首選回報爲零,則選取器視圖將回退到titleForRow
。爲什麼不通過UIPickerView調用TitleForRow?
我正在實施這兩種方法,並且attributedTitleForRow
永遠不會被調用。即使titleForRow
返回零,而attributedTitleForRow
返回NSAttributedString
,它也不會被調用。但是,titleForRow
總是被調用。
這是我有:
- (NSString *)pickerView:(UIPickerView *)pickerView
titleForRow:(NSInteger)row
forComponent:(NSInteger)component {
return @"Hello";
}
- (NSAttributedString *)pickerView:(UIPickerView *)pickerView
attributedTitleForRow:(NSInteger)row
forComponent:(NSInteger)component {
return [[NSAttributedString alloc] initWithString:@"World"];
}
如果只實現pickerView(_:attributedTitleForRow:forComponent :),那麼它是否被調用? – 3stud1ant3
檢查此https://stackoverflow.com/questions/18945119/uipickerview-nsattributedstring-not-available-in-ios-7 –
@ user1000不,仍然沒有調用,但viewForRow是 - 看起來像我將不得不那樣。 – ArielSD