私のブラウザー アプリケーションでは、応答が pdf ファイルの場合、NSURL 接続を使用してファイルをダウンロードしています。データを受信したら、UIprogressView を表示してダウンロード ステータスを表示します。ダウンロードが完了するまで、背景ビューの色を無効にして変更したい。
didReceiveResponse デリゲートでメソッドを呼び出して、progressView を作成し、backgroundcolor を変更して、parentView を無効にします。
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{
[self.fileData setLength:0];
self.totalFileSize = response.expectedContentLength;
[self performSelectorOnMainThread:@selector(startProgressView) withObject:nil waitUntilDone:NO];
}
-(void) startProgressView
{
CGSize frameSize = self.view.frame.size;
CGFloat margin = 30.0;
CGPoint center = self.view.center;
topLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, margin, frameSize.width-2*margin, 20.)];
bottomLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, margin, frameSize.width-2*margin, 20.)];
[topLabel setText:@"downloading file"];
[topLabel setCenter:CGPointMake(center.x, center.y - 20.)];
[topLabel setTextAlignment:NSTextAlignmentCenter];
[bottomLabel setText:@"downloadstatus"];
[bottomLabel setCenter:CGPointMake(center.x, center.y + 20.)];
[bottomLabel setTextAlignment:NSTextAlignmentCenter];
self.progressBar = [[UIProgressView alloc] initWithFrame:
CGRectMake(0, margin, frameSize.width-2*margin, 20.)];
[self.progressBar setProgress:0];
[self.progressBar setCenter:center];
[self.view addSubview:topLabel];
[self.view addSubview:(self.progressBar)];
[self.view addSubview:bottomLabel];
/*
CGRect frame = CGRectMake(0.0, 0, self.view.bounds.size.width, self.view.bounds.size.height);
UIView *v = [[UIView alloc] initWithFrame:frame];
[v setBackgroundColor:[[UIColor alloc] initWithRed:255.0
green:0.0
blue:0.0
alpha:0.1]];
[self.view insertSubview:v atIndex:0];
[v release];
*/
[self.view setBackgroundColor: [UIColor colorWithRed:0.0 green:255.0 blue:128.0/255 alpha:0.5]];
[self.view setUserInteractionEnabled:NO];
}
背景色を設定して、色付きの新しいビューを挿入しようとしましたが、背景色は変わりません。私が見逃しているものがあれば、誰かが指摘できますか。