好的,所以当我尝试接收用户个人资料图片时,图片返回一个带有问号的白色框?
这是我的代码:
func getProfilePic(fid: String) -> SKTexture? {
let imgURL = NSURL(string: "http://graph.facebook.com/" + fid + "/picture?type=large")
let imageData = NSData(contentsOfURL: imgURL!)
let imageUI = UIImage(data: imageData!)
let image = SKTexture(image: imageUI!)
return image
}
func getFBUserData() {
if((FBSDKAccessToken.currentAccessToken()) != nil) {
FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "id, name, first_name, last_name, email, picture"]).startWithCompletionHandler({ (connection, result, error) -> Void in
if (error == nil){
print(result)
if let userData = result as? NSDictionary {
personalUserID = userData["id"] as! String
}
} else {
print("error")
}
})
}
picture.texture = getProfilePic("\(personalUserID)")
如何让它显示正确的图片?