내 응용 프로그램에서 서버에서 오디오 파일을 다운로드하고 응용 프로그램이 포 그라운드에있을 때 파일을 다운로드하고 홈 버튼이나 잠금 버튼을 클릭하여 응용 프로그램을 백그라운드로 강제 실행 한 후 잠시 후 다운로드가 중지되고 오류는 1005 network connection lost
과 같이 나타납니다. 뭐가 문제 야? 아무도이 문제를 설명 할 수 있습니까?백그라운드 모드에서 파일을 다운로드하는 방법 iOS? 네트워크 연결이 끊어졌습니다.
코드 :
NSURL *url = [NSURL URLWithString:currentURL];
NSURLRequest *theRequest = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60];
receivedData = [[NSMutableData alloc] initWithLength:0];
NSURLConnection * connection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self startImmediately:YES];
myConnection = connection;
NSLog(@"%@ Download Started", currentURL);
- (void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
[receivedData setLength:0];
expectedBytes = [response expectedContentLength];
}
- (void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
[receivedData appendData:data];
float progressive = (float)[receivedData length]/(float)expectedBytes;
[downloadProgressView setProgress:progressive];
NSInteger val = progressive*100;
downloadpercentageLabel.text = [NSString stringWithFormat:@"%ld%@",(long)val,@"%"];
//[UIApplication sharedApplication].idleTimerDisabled = YES;
}
- (void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}
백그라운드 모드에서 백그라운드 가져 오기를 확인 하시겠습니까? –
이것은 중복되었을 수 있습니다. 이 질문을 확인한 적이 있습니까? http://stackoverflow.com/questions/8861390/ios-background-downloads-when-the-app-is-not-active? –
@ MehmetEfeAkça 여러 답변을 시도했지만 해결하지 못했습니다. 그리고 대답을 찾을 수 없습니다.^{ [: 나는 배경이 프로젝트를 선택 –