MBProgressHUDの使い方
890 ワード
プロジェクトの中で、いつもピクチャーあるいはその他の内容のダウンロードの進度を表示する必要があって、MBProgressHUDは1つの優秀なオープンソースの進度の表示のコントロールで、便利で簡単で、以下はその使用方法を紹介します
//初期化
//ダウンロード中の進捗
//ダウンロード完了後、非表示
//初期化
MBProgressHUD *loadingView = [[[MBProgressHUD alloc]initWithView:self.view]autorelease];
loadingView.labelText = @" ...";
[self.view addSubview:loadingView];
[loadingView setMode:MBProgressHUDModeDeterminate]; //
loadingView.taskInProgress = YES;
[loadingView show:YES]; //
//ダウンロード中の進捗
NSLog(@"size:%lld,total:%lld",size,total);
downloadedBytes += size;
CGFloat progressPercent = (CGFloat)downloadedBytes/total; //
loadingView.progress = progressPercent;
//ダウンロード完了後、非表示
[loadingView hide:YES];