i am trying to load a Logo image in to a UiImage the logo image is in parse but not sure how to load it in to the viewcontroller
.h file
@property (weak, nonatomic) IBOutlet UIImageView *Logo;
.m File
self.Logo.image = [self.exam objectForKey:@"Logo"];
it throws the following error
-[PFFile size]: unrecognized selector sent to instance
so i have to use PFfile but not sure how to format it i have searched but most examples have a query invoiled and i dont need the query as the data is there ready in
self.exam objectForKey:@"Logo"
now added
[self.exam objectForKey:@"Logo"];
self.Logo.image = [[UIImage alloc] initWithData: [self.exam objectForKey:@"Logo"]];
but get the following error the image is a .png
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PFFile length]: unrecognized selector sent to instance
NSlog is showing the file as
Logo = "<PFFile: 0x111875190>";
[self.exam objectForKey:@"Logo"];
Is instance of class PFFile
but not UIImage
. You should convert it. You can try following:
self.Logo.image = [[UIImage alloc] initWithData: [[self.exam objectForKey:@"Logo"] getData]];
PFFile
is a subclass of NSObject
, thus the UIImage
' length
method cannot be called, resulting to your NSInvalidArgumentException.
You should use an PFImageView
instead of your UIImageView.
.h file
@property (weak, nonatomic) IBOutlet PFImageView *Logo;
.m file
self.Logo.file = [self.exam objectForKey:@"Logo"];
[self.Logo.loadInBackground];
A loadInBackground:
method with completion block is also available.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.