如何使用Facebook iOS SDK取消正在进行的视频上传? [英] How to cancel a video upload in progress using the Facebook iOS SDK?

查看:164
本文介绍了如何使用Facebook iOS SDK取消正在进行的视频上传?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Facebook iOS SDK将我的应用程序的视频发布到用户的Facebook。

I'm using the Facebook iOS SDK to post videos from my app to the user's facebook.

我试图允许用户取消上传后上传已经开始。

I'm trying to allow the user to cancel the upload after the upload has started.

这些是开始上传的方法:

These are the methods that starts the upload:

- (void)startUpload
{   
    NSArray* permissions = [[NSArray alloc] initWithObjects:
                            @"publish_stream", nil];
    [facebook authorize:permissions];
    [permissions release];
}

- (void)fbDidLogin
{
    NSString *filePath = [videoNSURL path];

    NSData *videoData = [NSData dataWithContentsOfFile:filePath];
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   videoData, @"video.mov",
                                   @"video/quicktime", @"contentType",
                                   videoTitle, @"title",
                                   videoDescription, @"description",
                                   nil];
    [facebook requestWithGraphPath:@"me/videos"
                         andParams:params
                     andHttpMethod:@"POST"
                       andDelegate:self];
}

我在中找不到任何方法Facebook.h 这是Facebook的iOS SDK,它允许我取消上传。

I cannot find any methods inside Facebook.h that comes with the Facebook iOS SDK that allows me to cancel the upload.

即使我做了一个 ] ,它仍然不会取消试图上传视频的FBSession。这意味着当FBSession尝试通知 facebook 对象时,上传完成后,我会得到一个 exc_bad_access 完成

Even if I do a [facebook release], it will still not cancel the FBSession which is trying to upload the video. Which means I'll get a exc_bad_access when the upload is complete when FBSession tries to inform the facebook object that the upload is complete.

推荐答案

我添加了以下方法:

strong> FBRequest

FBRequest

(void) cancel {
   [_connection cancel];
   [_connection release], _connection = nil;
}

Facebook

(void)cancelPendingRequest {
  [_request cancel];
  [_request release], _request = nil;
}

cancelPendingRequest 将允许我取消正在进行的视频上传。

cancelPendingRequest will allow me to cancel a video upload in progress.

这篇关于如何使用Facebook iOS SDK取消正在进行的视频上传?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆