问题
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:
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
来源:https://stackoverflow.com/questions/30555713/how-can-i-use-a-pfimageview-in-swift