So zeigen Sie ProgressBar mit AFNetworking AFHTTPRequestOperationManager an

Ich versuche, die Fortschrittsleiste anzuzeigen, während ich eine JSON-Datei von einer URL herunterlade. Der JSON wird korrekt heruntergeladen, aber ich bin nicht sicher, wie die Fortschrittsanzeige angezeigt werden soll. Ich habe versucht mitUIProgressView wird aber nicht auf dem Bildschirm angezeigt. Anregungen wäre dankbar.

CGFloat width = [UIScreen mainScreen].bounds.size.width;
CGFloat height = [UIScreen mainScreen].bounds.size.height;

CGRect rect = CGRectMake(width/2, height/2, width/5, height/5);
UIProgressView *myProgressView = [[UIProgressView alloc]initWithFrame:rect];
myProgressView.progressViewStyle = UIProgressViewStyleBar;
[self.view addSubview:myProgressView];

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];    
[manager GET:@"https:urlWithJson" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
      [operation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead)
       {
           myProgressView.progress = (float)totalBytesRead / totalBytesExpectedToRead;
       }];
      [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
          NSLog(@"operation Completed");
      } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
          NSLog(@"ERROR");
      }];

      [operation start];
  } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
      NSLog(@"timeout Error: %@", error);
  }];

Antworten auf die Frage(4)

Ihre Antwort auf die Frage