我希望在我的iPhone应用上传图片到Facebook时显示一个进度条,这是否可行?
我能在每个FBRequest中都这样做吗?我还使用FBRequest来检查扩展权限,有时需要很长时间。
谢谢。
我希望在我的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时遇到任何问题,请告诉我。
你无法知道何时会登录,但可以放置一个UIActivityIndicatorView。 当您单击发布按钮时启动它,并在进入“didConnect”方法时结束它。