谁需要帮助!这是解决方案。所有学分都归@ACB!!!
-(UIView *)pickerView:(UIPickerView *)pickerView
viewForRow:(NSInteger)row
forComponent:(NSInteger)component reusingView:(UIView *)view
{
//NSLog(@"%d",component);
// NSLog(@"tag: %d",pickerView.tag);
if(pickerView.tag==1)
{
NSString *arrayName = [[NSString alloc] initWithFormat:@"column%d",component+1];
NSArray *array1 = [self valueForKey:arrayName];
UIImageView *imageView = [array1 objectAtIndex:row];
if ([pickerView selectedRowInComponent:component] == row) {
imageView.frame = CGRectMake(60,60,40,80);//set bigger frame
} else {
imageView.frame = CGRectMake(30,30,20,60);//set normal frame
}
return imageView;
//NSString *arrayName = [[NSString alloc] initWithFormat:@"column%d",component+1];
//NSArray *array1 = [self valueForKey:arrayName];
//return [array1 objectAtIndex:row];
}
else if([pickerView isEqual:picker2])
{
NSString *arrayName = [[NSString alloc] initWithFormat:@"column%d",component+5];
NSArray *array1 = [self valueForKey:arrayName];
UIImageView *imageView = [array1 objectAtIndex:row];
if ([pickerView selectedRowInComponent:component] == row) {
imageView.frame = CGRectMake(60,60,40,80);//set bigger frame
} else {
imageView.frame = CGRectMake(30,30,20,60);//set normal frame
}
return imageView;
/* NSString *arrayName = [[NSString alloc] initWithFormat:@"column%d",component+5];
NSArray *array2 = [self valueForKey:arrayName];
return [array2 objectAtIndex:row];*/
}
else
{
NSString *arrayName = [[NSString alloc] initWithFormat:@"column%d",component+9];
NSArray *array1 = [self valueForKey:arrayName];
UIImageView *imageView = [array1 objectAtIndex:row];
if ([pickerView selectedRowInComponent:component] == row) {
imageView.frame = CGRectMake(60,60,40,80);//set bigger frame
} else {
imageView.frame = CGRectMake(30,30,20,60);//set normal frame
}
return imageView;
/* NSString *arrayName = [[NSString alloc] initWithFormat:@"column%d",component+9];
NSArray *array3 = [self valueForKey:arrayName];
return [array3 objectAtIndex:row];*/
}
}
- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component
{
return 120.0;
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
[pickerView reloadComponent:component];
}