-1

iOS アプリのバックエンドとして Parse.com を使用しています。

「ユーザー」というクラスがあります。このクラスでは、ユーザーのプロフィール写真を含む「写真」と呼ばれるフライドがあります。

現時点では、現在のユーザーのこの画像を取得し、ストーリーボード ビュー コントローラー内の UIView (UIImage ではない) 内に表示する方法にちょっとこだわっています。

たぶん、そのためのサンプルコードがありますか?

前もって感謝します!

4

1 に答える 1

0

アミット、申し訳ありませんが、コードが機能しませんでした。アプリがクラッシュしました。

これが私の解決策です:

PFUser *cUser = [PFUser currentUser];

PFFile *pictureFile = [cUser objectForKey:@"picture"];

        [pictureFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
            if (!error){
                [_currentUserImage setImage:[UIImage imageWithData:data]];
            }
            else {
                NSLog(@"no data!");
                [_currentUserImage setImage:[UIImage imageNamed:@"profile"]]; //Set Custom Image if there is no user picture.

            }
        }];

    }
于 2014-06-08T15:33:03.330 に答える