Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.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
Ios5 获取UIImage参考_Ios5_Uiimage - Fatal编程技术网

Ios5 获取UIImage参考

Ios5 获取UIImage参考,ios5,uiimage,Ios5,Uiimage,我对UIImage有点着迷 在我的应用程序目录中,我有3张不同标志(red.png、yellow.png、green.png)的图片,它们表示警报的不同严重程度。我创建了一个类“Alerte”,其中一个参数是从这些标志中选择的UIImage。所以我引用了这样一幅图像: NSString *filePath = [[NSBundle mainBundle] pathForResource:@"jaune" ofType:@"png"]; UIImage *img = [[UIImage alloc

我对UIImage有点着迷

在我的应用程序目录中,我有3张不同标志(red.png、yellow.png、green.png)的图片,它们表示警报的不同严重程度。我创建了一个类“Alerte”,其中一个参数是从这些标志中选择的UIImage。所以我引用了这样一幅图像:

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"jaune" ofType:@"png"];
UIImage *img = [[UIImage alloc] initWithContentsOfFile:filePath];
使用NSLog打印时,调试区域显示的图像如下:

2012-07-26 11:46:28.546 ApplicationFormulaire[1031:fb03] <UIImage: 0x8144e20>
2012-07-26 11:46:28.546应用公式[1031:fb03]
但我怎么知道这三面旗帜中哪一面被指出了呢?是黄色、红色还是绿色? 是否存在获取此资源名称的方法


如果有人能帮我处理,我将不胜感激:D谢谢

我不确定,但我不认为UIImage保留了有关其路径的信息


另一种允许您访问正确图像的方法是将它们存储在NSDictionary中。然后,您可以使用[myDict objectForKey:key]访问每一个,以获得红色、黄色或绿色图像。

您需要将所选的标志字符串传递给相应的警报方法/类感谢蚂蚁,UIImage没有保留信息真的很奇怪,但它与我在apple文档中看到的UIImage属性一致