ios - 从 Parse.com 将 Logo 图像加载到 UIImage

标签 ios xcode uiimage parse-platform

我正在尝试将 Logo 图像加载到 UiImage 中, Logo 图像正在解析中,但不确定如何将其加载到 View Controller 中

.h文件

@property (weak, nonatomic) IBOutlet UIImageView *Logo;

.m文件

self.Logo.image = [self.exam objectForKey:@"Logo"];

它抛出以下错误

-[PFFile size]: 无法识别的选择器发送到实例

所以我必须使用 PFfile 但不确定如何格式化我已经搜索过但是大多数示例都有一个查询被调用并且我不需要查询因为数据已经准备就绪

self.exam objectForKey:@"Logo"

现在添加

[self.exam objectForKey:@"Logo"];
self.Logo.image = [[UIImage alloc] initWithData: [self.exam objectForKey:@"Logo"]];

但出现以下错误图像是.png

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PFFile length]: unrecognized selector sent to instance

NSlog 将文件显示为

Logo = "<PFFile: 0x111875190>";

最佳答案

[self.exam objectForKey:@"Logo"];

PFFile 类的实例,但不是 UIImage 的实例。 你应该转换它。您可以尝试以下操作:

self.Logo.image = [[UIImage alloc] initWithData: [[self.exam objectForKey:@"Logo"] getData]];

关于ios - 从 Parse.com 将 Logo 图像加载到 UIImage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24868464/

相关文章:

ios - 更改 navigationItem.leftBarButtonItem 的位置

ios - 如何在iOS 6/7中将图像保存到相机胶卷/相册?

ios - 如何使用字典 iOS 在服务器上发布图像?

ios - 在 iOS 设备上运行时, ionic 栏标题不居中

ios - 约束 LefAnchor 常量不更新

ios - 无主在逻辑上等同于弱!在 swift

c++ - 从 XCode 远程调试 Linux 应用程序

ios - 代码 : module name "" is not a valid identifier while running XC unit test

ios - 切出一个 UIImage 以适应 UIImageView

iphone - 从HTML文件中提取所有&lt;script&gt;标记并将其存储在NSArray-Objective C中