선택한 행이 고유 한 텍스트 색으로 표시된 UIPickerView
을 표시하려고합니다. 따라서 선택된 행은 빨간색 글 C로 표시되고 다른 모든 (선택되지 않은) 행은 검은/기본 글 C로 표시됩니다.UIPickerView에서 시작 행의 텍스트 색을 변경하는 방법
내가 이것을 구현 :
완벽하게 선택을 변경할 때 작동하지만 표시되는 초기 행에 대해 아무것도하지 않는- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
UILabel *label = (UILabel*)[pickerView viewForRow:row forComponent:component];
label.textColor = [UIColor redColor];
UILabel *oldLabel = (UILabel*)[pickerView viewForRow:self.previouslySelectedRow forComponent:component];
oldLabel.textColor = [UIColor blackColor];
self.previouslySelectedRow = row;
}
. 나는 UIPickerView
를 표시
[pickerView selectRow:initialRow inComponent:0 animated:NO];
후,하지만 난이 (사용자가 수동으로 선택을 변경하는 경우에만 발생하는 것이) 호출되는 didSelectRow
을 초래하지 않는다는 것을 깨달았다 :
내가 부르고있다.
나는 UILabel
textColor
값을 자신을 설정하는 시도 - 무언가 같이 :
UILabel *label = (UILabel*)[pickerView viewForRow:startingRow forComponent:0];
label.textColor = [UIColor redColor];
그러나 불행하게도 아무것도 결과가 일어나고있다. pickerview를 표시 한 후에 이것을 호출합니다.
이 작업을 수행하는 쉬운 방법이 있습니까? 내가 놓친 게 있니? 모든/모든 도움에 감사드립니다!
자크