가 선택한 행을 변경합니다 UIPickerView 위임 방법 - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
를 사용하여 첫 번째 행이 선택되어있는 경우 :
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
if (row == 0) {
[pickerView selectRow:row+1 inComponent:component animated:YES];
}
}
편집 :
- (NSAttributedString *)pickerView:(UIPickerView *)pickerView attributedTitleForRow:(NSInteger)row forComponent:(NSInteger)component {
if (row == 0)
return [[NSAttributedString alloc] initWithString:@"Pick a value" attributes:@{NSForegroundColorAttributeName:[UIColor lightGrayColor]}];
else {
// Return titles
}
}
: 당신은이를 사용하여 텍스트 색상을 변경할 수 있습니다
iOS 6 이상을 타겟팅하고 이전에 사용 된 -pickerView:titleForRow:forComponent:
메소드를 대체합니다.
작동합니다. 한 가지 더 질문 - 방법에서 회색으로 만드는 방법? 한 줄의 맞춤 텍스트와 색상을 만드는 방법은 무엇입니까? – Palindrome
@Palindrome :이 질문을 편집했습니다. – rdurand