Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/116.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 根据uiPickerView以编程方式更改图像_Ios_Image_Uipickerview_Message - Fatal编程技术网

Ios 根据uiPickerView以编程方式更改图像

Ios 根据uiPickerView以编程方式更改图像,ios,image,uipickerview,message,Ios,Image,Uipickerview,Message,我使用一个uiPickerView,它有图像而不是字符串作为选择,可以显示图像,我从apple UIcatalog示例中获得了关于如何放置图像的灵感 我是按程序实现的没有IB 所以问题是,如何根据选定的单元格更改图像 我有 *MainVC我的主视图控制器 *自定义视图定义选择器大小 *CustomPickerDataSource选择器的数据源: 在CustomPickerDataSource中,发送选定行的数据 - (void)pickerView:(UIPickerView *)pickerV

我使用一个uiPickerView,它有图像而不是字符串作为选择,可以显示图像,我从apple UIcatalog示例中获得了关于如何放置图像的灵感

我是按程序实现的没有IB

所以问题是,如何根据选定的单元格更改图像

我有 *MainVC我的主视图控制器 *自定义视图定义选择器大小 *CustomPickerDataSource选择器的数据源:

在CustomPickerDataSource中,发送选定行的数据

- (void)pickerView:(UIPickerView *)pickerView didSelectRow: (NSInteger)row inComponent:(NSInteger)component {
// Handle the selection
NSLog(@"seleccionokkkk: %d", row);
[MainVC entro:row];
}
而在我的主要

+(void) entro: (int) cuca {

NSLog(@"sumbalo :%d", cuca);
 }
我在MainVC上选择了单元格的数量,我想在这里显示不同的图像, 但是在my+void entro:int cuca中选择图像时 我当然会收到警告,因为Im使用类方法设置实例变量

那么,如何根据接收到的单元格编号显示图像呢

伪代码: 如果image==0,则显示image0

在哪里放置我的图像显示代码?以及如何设置传入消息的变量


非常感谢

我假设您的图像数量与拾取程序中的项目数量相同。按与在“选取器”视图中相同的顺序将它们放入数组中。然后获取要更改为所选图片的UIImageView,并将其设置为具有给定索引的数组中的图片

您可以在entro:method中执行此操作,它应该是一个实例方法,没有理由认为它不应该或不可能,或者您可以继续在pickerView:didSelectRow:method中执行此操作

您可以像这样设置图像:

UIImageView *myImageView;
NSArray *myImageArray;
...

- (void)pickerView:(UIPickerView *)pickerView didSelectRow: 
(NSInteger)row inComponent:(NSInteger)component {
    [myImageView setImage:[myImageArray objectAtIndex:row]];
}