사용자가 버튼을 클릭하여지도 세트를 다운로드 할 수 있으며 작업 완료시 진행 표시기를 숨기려고합니다. 나는 아래 코드의 몇 가지 변형을 시도했지만 내가 찾고있는 것을 달성하지 못했다. 모든 지침을 부탁드립니다.MBProgressHUD GCD 이후 숨기기 표시
- (IBAction)SavePhotoOnClick:(id)sender{
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
[self.navigationController.view addSubview:HUD];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
NSURL *url = [NSURL URLWithString:urlstr1];
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:url]];
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil); dispatch_async(dispatch_get_main_queue(), ^{
[MBProgressHUD hideHUDForView:self.view animated:YES];
});
});
// Set determinate mode
HUD.mode = MBProgressHUDModeDeterminate;
HUD.dimBackground = YES;
HUD.color = [UIColor colorWithRed:0.23 green:0.50 blue:0.82 alpha:0.90];
HUD.delegate = self;
HUD.labelText = @"Downloading Maps";
// myProgressTask uses the HUD instance to update progress
[HUD showWhileExecuting:@selector(myProgressTask) onTarget:self withObject:nil animated:YES];
}
- (void)myProgressTask {
// This just increases the progress indicator in a loop
float progress = 0.0f;
while (progress < 1.0f) {
progress += 0.01f;
HUD.progress = progress;
usleep(40000);
}
}
progresstask 메서드와 showWhileExecuting 코드를 제거하면 진행률 표시기가 제거됩니다. usleep은 모든 것을 무시하고 다운로드 완료 후 진행 표시기를 숨기지 않고 대신 4 초 후 제거합니다.
이 작업은 이전에 수행했습니다. 그러나 어떤 이유로 나는 그 전화를 사용하여 텍스트, 색상 등을 추가 할 수 없다. 나는 "다운로드 중 ..."이라는 텍스트를 추가 할 수 있다고 가정 할 때 진행 표시기의 확정 된 상태가 그렇게 크지 않다. . "어떤 protips? – 3722839
MBProgressHUD 인스턴스에는 모양을 사용자 지정하기 위해 설정할 수있는 "텍스트"같은 매개 변수가 있다고 생각합니다. –
그렇지만 현재 매개 변수가 작동하지 않는 것 같습니다. 나는 그것이 내가 생각하기에 조금 더 조사 할 필요가있을 것이다. – 3722839