Facebook iPhone SDK: Show a progress bar when uploading an image

I want to show a progress bar while the iPhone app uploads the image to Facebook. Is it possible?

Can I do this with every FBRequest that I do? I also use FBRequest to check for advanced resolution and sometimes takes a lot of time.

Thank.

+3
source share
2 answers

For a progress indicator, you can hack a bit. In the file, FBRequest.hadd this line to the protocol FBRequestDelegate:

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

After that, FBRequest.madd this function to the file :

- (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);
}

, SDK Facebook.

+6

, , UIActivityIndicatorView. , , , 'didConnect'

0

Source: https://habr.com/ru/post/1742826/


All Articles