NSData *imageData = UIImagePNGRepresentation(profileImage); PFfile *imagefile = [PFfile fileWithname:@"Profileimage.png" data:imageData]; [imagefile saveInBackground]; PFUser *user = [PFUser currentUser]; user[@"fullname"] = name; user[@"Location"] = location; user[@"gender"] = gender; user[@"email"] = email; user[@"ProfilePic"] = imagefile; [user saveInBackground];
问题是这似乎没有保存图像文件来解析,因为我的数据浏览器中没有填充任何内容.这里的代码看起来很好,但是你们可以看到它有什么问题吗?
使用以下代码从Facebook下载图像:
NSURL *pictureURL = [NSURL URLWithString:[Nsstring stringWithFormat:@"https://graph.facebook.com/%@/picture?type=large&return_ssl_resources=1",facebookID]]; NSData *data = [[NSData alloc] initWithContentsOfURL:pictureURL]; UIImage *profileImage = [[UIImage alloc] initWithData:data];
有任何想法吗?
谢谢
解决方法 问题是[imagefile saveInBackground];调用[user saveInBackground]时尚未执行 *** 作;当您调用第一个后台保存时,程序将继续.
改为使用saveInBackgrounDWithBlock,然后在那里执行[user saveInBackground] *** 作.
NSData *imageData = UIImagePNGRepresentation(profileImage);PFfile *imagefile = [PFfile fileWithname:@"Profileimage.png" data:imageData];[imagefile saveInBackgrounDWithBlock:^(BOol succeeded,NSError *error) { if (!error) { if (succeeded) { PFUser *user = [PFUser currentUser]; user[@"fullname"] = name; user[@"Location"] = location; user[@"gender"] = gender; user[@"email"] = email; user[@"ProfilePic"] = imagefile; [user saveInBackground]; } } else { // Handle error } }];总结
以上是内存溢出为你收集整理的Parse.com保存图像IOS全部内容,希望文章能够帮你解决Parse.com保存图像IOS所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)