进度栏完成后显示alertview

时间:2015-07-23 09:14:54

标签: ios objective-c iphone xcode

我有上传图片的应用程序到server.image正在成功上传到服务器,进度条也正常工作。但我想在进度栏完成后显示一个提醒视图...这是我的进度条代码。

- (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
{
     float progress = [[NSNumber numberWithInteger:totalBytesWritten] floatValue];
     float total = [[NSNumber numberWithInteger: totalBytesExpectedToWrite] floatValue];
     progress_bar.progress = progress/total;
     NSLog(@"%f",progress/total);
}

所以我的问题是如何在进度条为100%后显示alertview。

3 个答案:

答案 0 :(得分:2)

试试这个..

- (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
{
     float progress = [[NSNumber numberWithInteger:totalBytesWritten] floatValue];
     float total = [[NSNumber numberWithInteger: totalBytesExpectedToWrite] floatValue];

     float actualProgress = progress/total; 

     if (actualProgress == 1.0){
         //showAlert
     }
     progress_bar.progress = actualProgress;
     NSLog(@"%f",progress/total);
}

答案 1 :(得分:1)

你能否使用connectionDidFinishLoading委托方法?

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
    // show alert with UIAlertView or iOS8 UIAlertController
}

答案 2 :(得分:0)

var body = document.querySelector('body');
body.onload = function(){
   //do some thing
}