브라우저 응용 프로그램에서 응답이 PDF 파일이면 NSURL 연결을 사용하여 파일을 다운로드하고 있습니다. 데이터를 받으면 UIprogressView를 표시하여 다운로드 상태를 표시합니다. 다운로드가 완료 될 때까지 백그라운드보기의 색을 비활성화하고 변경하고 싶습니다. didReceiveResponse 위임에iOS에서보기의 배경색을 변경하십시오.
은 내가 배경 색상을 설정하고 변경되지 않는 색상이지만 배경색으로 새로운 뷰를 삽입 시도 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];
}
을 progressView을 만들고있는 backgroundColor을 변경하고 해제하는 메서드를 호출합니다. 누락 된 것이 있으면 누군가가 지적 할 수 있습니까?
색상 설정을 제외하고 다른 모든 기능이 작동합니까? (두 개의 레이블과 진행률 막대가 보입니까)? – rdelmar
예 배경색을 제외한 다른 모든 것이 작동합니다. 나는 그 이유를 알아 냈다. viewcontroller (self.view)의 주요 뷰는 그 위에 3 개의 하위 뷰를 포함하며 self.view의 배경색을 변경하는 것은 하위 뷰로 인해 보이지 않습니다. – codemaster