Rex*_*ids 17 iphone objective-c nsdictionary uiimage
如何在NSDictionary中存储UIImage?
Fel*_*oux 16
是的你可以:
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:1];
UIImage *img = ...;
[dict setObject:img forKey:@"aKeyForYourImage"];
UIImage *imgAgain = [dict objectForKey:@"aKeyForYourImage"];
Run Code Online (Sandbox Code Playgroud)
好的,我最近遇到了这个问题,上述解决方案对我来说没有用.因此,如果其他人在这里找到解决同样问题的方法,那么就是这样做的
NSDictionary *imageDictionary = @{
kImageKey: UIImageJPEGRepresentation(/*INSERT YOUR UIImage HERE*/,0.1)
};
Run Code Online (Sandbox Code Playgroud)
// 0.1表示压缩质量0.0最低为1.0是最高质量
然后从字典使用中获取图像
[UIImage imageWithData:[imageDictionary objectForKey: kImageKey]];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16294 次 |
| 最近记录: |