2010-04-26 115 views
3

我想在iPhone應用上傳圖片到Facebook時顯示進度條。可能嗎?Facebook iPhone SDK:在上傳圖片時顯示進度條

我可以使用我製作的每個FBRequest嗎?我也使用FBRequest來檢查擴展權限,有時需要很長時間。

謝謝。

+0

你有沒有解決這個進度條的事情?如果你確實可以,請分享你的解決方案? – 2011-08-02 09:56:29

+0

不,我很抱歉。我沒有找到解決方案。 – VansFannel 2011-08-02 11:25:17

+1

我做過 - 如果您仍然感興趣:) – 2011-08-02 11:35:07

回答

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任何問題。

+0

非常感謝! – VansFannel 2011-08-02 16:37:47

+0

沒問題!總是樂於幫助! – 2011-08-02 17:00:10

+0

你可以在最新的SDK 3.1中實現這個功能嗎?謝謝! – Jan 2012-12-20 03:48:51

0

你不能知道它何時會登錄你,但你可以把一個UIActivityIndi​​catorView。 當你點擊發布按鈕,你開始它,當你輸入'didConnect'方法時,它結束它

相關問題