How can I use a PFImageView in Swift?

对着背影说爱祢 提交于 2020-01-06 19:43:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!