Facebook iPhone SDK:上传图片时显示进度条

3

我希望在我的iPhone应用上传图片到Facebook时显示一个进度条,这是否可行?

我能在每个FBRequest中都这样做吗?我还使用FBRequest来检查扩展权限,有时需要很长时间。

谢谢。


你曾经解决过这个进度条的问题吗?如果解决了,能否请分享一下你的解决方案? - Mihai Fratu
不好意思,我没有找到解决方案。 - VansFannel
1
我已经完成了 - 如果你还感兴趣 :) - Mihai Fratu
是的,我仍然感兴趣。您能否回答我的问题并解释一下您的解决方案?谢谢。 - VansFannel
2个回答

6

对于进度条,有一个小技巧可以实现。在FBRequest.h文件中,将以下行添加到FBRequestDelegate协议中:

- (void)request:(FBRequest *)request didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite;

接下来在FBRequest.m文件中添加以下函数:

- (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite {
    if ([_delegate respondsToSelector:@selector(request:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite:)]) {
        [_delegate request:self didSendBodyData:bytesWritten totalBytesWritten:totalBytesWritten totalBytesExpectedToWrite:totalBytesExpectedToWrite];
    }
}

现在,每当服务器发布更多数据时,您的代理将接收到一条消息。因此,如果您将其实现到您的代理中,您应该会在日志中看到一些活动:
- (void)request:(FBRequest *)request didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
{
    NSLog(@"%d bytes out of %d sent.", totalBytesWritten, totalBytesExpectedToWrite);
}

如果您在将此内容应用到当前的Facebook SDK时遇到任何问题,请告诉我。


你能帮我在最新的SDK 3.1中实现这个吗?谢谢! - Jan

0

你无法知道何时会登录,但可以放置一个UIActivityIndicatorView。 当您单击发布按钮时启动它,并在进入“didConnect”方法时结束它。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接