2015-07-23 2 views
-2

У меня есть приложение для загрузки изображений на server.image, загрузка на сервер успешно, и progressbar также работает. Но я хочу показать предупреждение после того, как progressbar будет выполнен ... вот мой код для progressbar.show alertview после progressbar done

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

+0

'if (progress == total) {showAlert}'? – Larme

+0

Или это может быть 'float actualProgress = progress/total; if (actualProgress == 1.0) {showAlert} ' – iphonic

ответ

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); 
} 
+0

да ... это сработало .. –

0
if (progress_bar.progress == 1){ 
    //Add your alertview here. 
} 
+0

нет его не работает .. –

+0

В чем проблема? –

+0

индикатор выполнения уже выполнен, но нет alertview pop –

1

Можете ли вы не использовали метод connectionDidFinishLoading делегата?

- (void)connectionDidFinishLoading:(NSURLConnection *)connection { 
    // show alert with UIAlertView or iOS8 UIAlertController 
} 
Смежные вопросы