6

を使用して Instagram をアプリケーションに統合していますinstagram-ios-sdk。Instagramへは正常にアクセストークンを取得できるのですが、その後fromloginを使って写真を投稿しようとすると画像が投稿されません。画像を送信するコードは次のとおりです。UIDocumentInteractionControllerUIImagePickerController

(void)_startUpload:(UIImage *) image {
    NSLog(@"Image Object = %@",NSStringFromCGSize(image.size));
    NSString  *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Test.igo"];
    [UIImageJPEGRepresentation(image, 1.0) writeToFile:jpgPath atomically:YES];
    NSLog(@"file url  %@",jpgPath);

    NSURL *igImageHookFile = [[NSURL alloc] init];
igImageHookFile = [NSURL fileURLWithPath:jpgPath];
NSLog(@"File Url = %@",igImageHookFile);

    documentInteractionController.UTI = @"com.instagram.photo";
    [UIDocumentInteractionController interactionControllerWithURL:igImageHookFile];
    [self setupControllerWithURL:igImageHookFile usingDelegate:self];

    [documentInteractionController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
}

(UIDocumentInteractionController *) setupControllerWithURL: (NSURL*) fileURL  usingDelegate: (id <UIDocumentInteractionControllerDelegate>) interactionDelegate {
    NSLog(@"%@",fileURL);
    UIDocumentInteractionController *interactionController =
        [UIDocumentInteractionController interactionControllerWithURL: fileURL];
    interactionController.delegate = interactionDelegate;

    return interactionController;
}

.ig画像を(612 * 612)の解像度でフォーマットに変換しました。しかし、まだ画像は に投稿されていませんInstagram。何か不足していますか?誰でもこれで私を助けることができますか?

ありがとう

4

1 に答える 1

0

まず、コードでは、戻り値をsetupControllerWithURL: usingDelegate:オブジェクトに割り当てていないため、メソッドは実際には何も達成せず、UIDocumentInteractionController の新しいインスタンスを作成して破棄するだけです。

次に、ドキュメントから:

"Note that the caller of this method needs to retain the returned object."

私が知る限り、ドキュメントコントローラーを保持していません(または、ARCの場合は強く参照されたプロパティに割り当てていません)。

これを試してください - あなたの @interface で:

@property (nonatomic, strong) UIDocumentInteractionController *documentController;

あなたの @implementation で:

self.documentController = [UIDocumentInteractionController interactionControllerWithURL:igImageHookFile];
self.documentController.delegate = self;
self.documentController.UTI = @"com.instagram.photo";
[self.documentController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];

また、次の行で新しいインスタンスを作成し、最初のインスタンスを破棄しているNSURL *igImageHookFile = [[NSURL alloc] init];ため、この行は不要です。igImageHookFile = [NSURL fileURLWithPath:jpgPath];使うだけNSURL *igImageHookFile = [NSURL fileURLWithPath:jpgPath];

于 2013-04-02T22:19:50.183 に答える