I am trying to display an image in an UIImageView that i classed as PFImageView in the inspector and connected it to my detail controller.I am pulling the image from my Tableview array and sending it through prepare segue using

detailVC.image= [[Booksarray objectAtIndex:indexPath.row]objectForKey:@"BookImage"];

In detail controller i have two properties to help with this

@property (weak, nonatomic) IBOutlet PFImageView *BookImage;
@property (retain,nonatomic) PFFile * image;

and in the detail controller implementation i call them to display in view did load:

    BookImage.file=_image;
    [BookImage loadInBackground];

when I run the code though i get this error and my app crashes:

-[UIImageView setFile:]: unrecognized selector sent to instance 0xcb7bd70

有帮助吗?

解决方案

It seems that the PFImageView class may not be getting loaded properly so the incorrect class type is created (UIImageView).

As a workaround, add the code:

[PFImageView class];

somewhere in your app delegate / cell subclass + initialize to force the class to load.

Alternatives would be:

  1. -all_load -ObjC linker flags
  2. Calling any other method on the class anywhere before the cell is loaded from the storyboard / XIB
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top