是否可以在同一选择器视图中显示行标题和行视图?我想做的是让人们能够为我正在编写的时间表应用程序选择主题房间号和颜色。我希望颜色选择是图像。它显示图像但不显示标题。
-(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;
}