我想在我的 iPhone 应用程序将图像上传到 Facebook 时显示进度条。是否可以?
我可以对我发出的每个 FBRequest 执行此操作吗?我还使用 FBRequest 来检查扩展权限,有时需要花费很多时间。
谢谢。
对于进度条,您可以做一些小修改。在里面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 中时遇到任何问题,请告诉我。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)