アプリのバックエンドとして Parse を使用していますが、画像に示すように、プロフィール写真が正しく表示されていないようです。
john_appleseed の写真に黒い帯があります。
プロフィール画像を保存するための私のコードは次のとおりです。
NSData *profileData = UIImagePNGRepresentation(cell1.profileView.image);
PFFile *profileFile = [PFFile fileWithName:@"profilePhoto" data:profileData];
[profileFile saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error)
{
if (!error)
{
if (succeeded)
{
[user setObject:profileFile forKey:@"profilePhoto"];
[user saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error)
{
if (!error)
{
}
else
{
}
}];
}
}
}];
画像を取得する方法は次のとおりです:(PFQueryTableViewController内)
- (PFQuery *)queryForTable
{
//NSLog(@"called");
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
NSString *filter = [defaults objectForKey:@"topicFilter"];
NSLog(@"queryfortable: %@", filter);
PFQuery *query = [PFQuery queryWithClassName:@"Questions"];
[query includeKey:@"user"];
[query whereKey:@"category" equalTo:filter];
[query orderByDescending:@"createdAt"];
return query;
}
- (PFObject *)objectAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == self.objects.count)
{
return nil;//this is for the load more cell.
}
return [self.objects objectAtIndex:indexPath.section];
}
の- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object
PFUser *user = [object objectForKey:@"user"];
PFImageView *profileImgView = (PFImageView *)[cell viewWithTag:1];
profileImgView.layer.cornerRadius = profileImgView.frame.size.height/2;
profileImgView.layer.masksToBounds = YES;
PFFile *file = user[@"profilePhoto"];
profileImgView.file = file;
[profileImgView loadInBackground];
何か案は?どうもありがとう。