Ios progressbar完成后显示alertview
我有用于将图像上载到服务器的应用程序。图像正在成功上载到服务器,progressbar也在工作。但我想在progressbar完成后显示alertview。。。这是我的progressbar代码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
- (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,让我们来看看。