Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios progressbar完成后显示alertview_Ios_Objective C_Iphone_Xcode - Fatal编程技术网

Ios progressbar完成后显示alertview

Ios progressbar完成后显示alertview,ios,objective-c,iphone,xcode,Ios,Objective C,Iphone,Xcode,我有用于将图像上载到服务器的应用程序。图像正在成功上载到服务器,progressbar也在工作。但我想在progressbar完成后显示alertview。。。这是我的progressbar代码 - (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpect

我有用于将图像上载到服务器的应用程序。图像正在成功上载到服务器,progressbar也在工作。但我想在progressbar完成后显示alertview。。。这是我的progressbar代码

- (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);
}
因此,我的问题是如何在progressbar为100%后显示alertview。

试试这个

if (progress_bar.progress == 1){
    //Add your alertview here. 
}
- (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);
}

您不能使用
connectiondFinishLoading
delegate方法吗

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

if(progress==total){showart}
?或者它可以是
float actualProgress=progress/total;如果(actualProgress==1.0){showAlert}
我已经将浮点值取为1.0,让我们来看看。