0
是否可以在同一個選取器視圖中顯示行的行標題和行的視圖?我想要做的是讓人們能夠爲我正在編寫的時間表應用程序選擇一個主題房間號和顏色。我希望顏色選擇是一個圖像。它顯示的圖像,但不是標題。UIPickerView - 顯示圖像和文字
-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row
forComponent:(NSInteger)component
{
if (component == kSubjects) return [PSubjects objectAtIndex:row];
if (component == kDay) return [PDays objectAtIndex:row];
//if (component == kLesson) return [PLessonPeriods objectAtIndex:row];
return [PRoomChoices objectAtIndex:row];
NSString *title;
title = [@"" stringByAppendingFormat:@"%d",row];
return title;
}
-(UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:
(NSInteger)component reusingView:(UIView *)view
{
if (component == kLesson) {
UIImageView *myIcon = [[UIImageView alloc] initWithImage:[PLessonPeriods
objectAtIndex:row]];
[myIcon setFrame:CGRectMake(0, 0, 50, 20)];
return myIcon;}
else return 0;
}