How can I use a PFImageView in Swift?

1.6k views Asked by At

I've tried simply dragging one into my storyboard, but there all I can find is UIImageView. In my IBOutlet for the UIImageView, I changed it to a PFImageView, and I get an error saying: "Use of undeclared type: 'PFImageView'"

Do PFImageViews simply not exist in swift?

1

There are 1 answers

3
RJH On

You need to ensure that you have the Parse SDK installed. You also need to ensure that you import the ParseUI on the class you are using, for example:

import ParseUI

You can then, on your Storyboard, select a normal ImageView, go to the Identity Inspector on your interface builder, change its class from UIImageView to PFImageView

Connect it as an outlet as normal to your code, but instead of connecting as a UIImageView ensure it is a PFImageView, like this:

@IBOutlet weak var imgTestImage :PFImageView!

You now have access to the PFImageView attributes such as:

let theImage = yourObject.valueForKey("profileImage") as? PFFile
imgTestImage.file = theImage
imgTestImage.loadInBackground()

Hope this helps