2009-10-31 66 views
3

我的應用程序將圖像上傳到我的服務器。 我想通過進度條顯示此事件。將上傳圖像上傳到我的服務器時顯示進度條

- (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite 

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response 

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data 

- (void)connectionDidFinishLoading:(NSURLConnection *)connection 

我用這個上面的方法來查看控制檯中的指令。 但我怎麼做在使用'進度欄'的筆尖文件?

+0

我知道這是一個非常古老的quesiton,不過是你永遠能做到這個?任何想法如何使用這個最新的Facebook SDK 3.1?謝謝! – Jan 2012-12-20 03:58:10

回答

15

如果你使用一個UIProgressView可以設置在連接進度:像這樣的方法:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite

float progress = [[NSNumber numberWithInteger:totalBytesWritten] floatValue]; 
float total = [[NSNumber numberWithInteger: totalBytesExpectedToWrite] floatValue]; 
progressView.progress = progress/total; 
+4

爲什麼要實例化一個NSNumber,當你可以免費投射值? – brian 2011-10-04 22:37:25

+2

progressView.progress =(float)totalBytesWritten/totalBytesExpectedToWrite – 2012-06-13 01:13:44

相關問題