我正在尝试使用Snapchat克隆进行解析,一切都很顺利,但是当我必须为用户显示图像时,PFImageView没有显示,我不知道因为没有错误显示只是没有子视图。
违规部分:
func checkForMessages() {
if PFUser.currentUser()?.username != nil {
println("checking for msgs")
var query = PFQuery(className: "Image")
query.whereKey("recipientUsername", equalTo: PFUser.currentUser()!.username!)
var msgs = query.findObjects()
println("\(msgs?.count) \(PFUser.currentUser()!.username!) recipientUsername")
var done = false
if let msg = msgs as? [PFObject] {
for msgReceived in msg {
if done == false {
var imageView: PFImageView = PFImageView()
imageView.file = msgReceived["image"] as? PFFile
imageView.loadInBackground({
(photo, error) -> Void in
if error == nil {
var displayedImage = UIImageView(frame: CGRectMake(0, 0, self.view.frame.width, self.view.frame.height))
displayedImage.image = photo
println(photo!.description)
self.view.addSubview(imageView) //here it should place it in the view
}
})
done = true
}
}
}
println(msgs?.count)
} else {
println("waiting for user this should be not showing")
}
}
答案 0 :(得分:0)
检查您的支持文件/ ParseStarterProject-Bridging-Header.h文件,看看它是否缺少以下行:
#import <ParseUI/ParseUI.h>
如果是这样,请务必添加。