gpt4 book ai didi

iphone - 将图像上传到我的服务器时显示进度条

转载 作者:行者123 更新时间:2023-12-03 19:28:05 25 4
gpt4 key购买 nike

我的应用程序将图像上传到我的服务器。我想通过进度条显示此事件。

- (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

我使用上述方法来查看控制台中的进度。但我如何使用“进度条”在 nib 文件中做到这一点?

最佳答案

如果您使用 UIProgressView,您可以在 connection:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite: 方法中设置进度,如下所示:

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

关于iphone - 将图像上传到我的服务器时显示进度条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1654012/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com