아래 기능은 서버에서 콘텐츠를 다운로드하지 않고 ASIHTTPRequestErrorDomain Code = 4"요청을 취소했습니다.ASIHTTPRequestErrorDomain Code = 4 "요청이 취소되었습니다.
이 함수는 viewdidload에서 호출됩니다. 그러나 동일한 URL이 제대로 작동하고 - (void) downLoad : (id) 보낸 사람 이벤트 : (id) 이벤트 함수에서는 내용을 잘 다운로드하지만 - (void) startDownload 함수입니다. 아래의 기능이 아닌 미세
-(void)downLoad:(id)sender event:(id)event{
self.tblViewDownload.userInteractionEnabled = NO;
IsRequestCompleted = NO;
CGPoint touchPosition = [[[event allTouches] anyObject] locationInView:self.tblViewDownload];
NSIndexPath *indexPath = [self.tblViewDownload indexPathForRowAtPoint:touchPosition];
UITableViewCell *Cell = [self.tblViewDownload cellForRowAtIndexPath:indexPath];
progress = [[UIProgressView alloc]initWithProgressViewStyle:UIProgressViewStyleBar];
progress.frame = CGRectMake(65, 55, 210, 25);
progress.progress = 0.0;
[Cell.contentView addSubview:progress];
UIButton* button = (UIButton*)sender;
button.hidden=YES;
if(!self.networkQueue)
self.networkQueue = [[[ASINetworkQueue alloc] init] autorelease];
[self.networkQueue cancelAllOperations];
[self.networkQueue setQueueDidFinishSelector:@selector(queueCompleted:)];
[self.networkQueue setShowAccurateProgress:YES];
[self.networkQueue setDownloadProgressDelegate:progress];
[self.networkQueue setDelegate:self];
NSDictionary *aDict =[self.myUrlArray objectAtIndex:[indexPath row]];
NSString *aImgUrl = [aDict objectForKey:@"IMG_URL"];
NSString *aVideoUrl = [aDict objectForKey:@"VIDEO_URL"];
NSString *aAudioUrl = [aDict objectForKey:@"AUDIO_URL"];
NSArray *aPoemArrayUrls = [NSArray arrayWithObjects:aImgUrl,aVideoUrl,aAudioUrl,nil];
for(NSString* urlString in aPoemArrayUrls)
{
NSURL *url = [NSURL URLWithString:urlString];
ASIHTTPRequest *downloadAFileRequest = [[ASIHTTPRequest requestWithURL:url]retain];
NSString *Filename = [urlString lastPathComponent];
NSLog(@"%@ filename",Filename);
[downloadAFileRequest setUserInfo:[NSDictionary dictionaryWithObject:@"request1" forKey:@"name"]];
[downloadAFileRequest setDownloadDestinationPath:[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:Filename]];
[downloadAFileRequest setShouldContinueWhenAppEntersBackground:YES];
[downloadAFileRequest setDelegate:self];
[downloadAFileRequest setDidFinishSelector:@selector(requestDone:)];
[downloadAFileRequest setDidFailSelector:@selector(requestWentWrong:)];
[downloadAFileRequest setShowAccurateProgress:YES];
[self.networkQueue addOperation:downloadAFileRequest];
//----
}
[self.networkQueue go];
}
을하고있다 - ((무효) startDownload) 함수 아래
내 기능에 문제/잘못된 일이 무엇인지 알려주세요 ASIHTTPRequestErrorDomain Code = 4 "요청이 취소되었습니다.
-(void)startDownload{
if([self.myUrlArray count] > 0){
int count = [self.myUrlArray count];
int i = count - count;
NSLog(@"%d iiiiii",i);
NSIndexPath *myIP = [NSIndexPath indexPathForRow:i inSection:0];
UITableViewCell *Cell = [self.tblViewDownload cellForRowAtIndexPath:myIP];
progress = [[UIProgressView alloc]initWithProgressViewStyle:UIProgressViewStyleBar];
progress.frame = CGRectMake(65, 55, 210, 25);
progress.progress = 0.0;
progress.backgroundColor = [UIColor redColor];
[Cell.contentView addSubview:progress];
if(!self.networkQueue)
self.networkQueue = [[[ASINetworkQueue alloc] init] autorelease];
[self.networkQueue cancelAllOperations];
[self.networkQueue setQueueDidFinishSelector:@selector(queueCompleted:)];
[self.networkQueue setShowAccurateProgress:YES];
[self.networkQueue setDownloadProgressDelegate:progress];
[self.networkQueue setDelegate:self];
NSDictionary *aDict =[self.myUrlArray objectAtIndex:[myIP row]];
NSString *aImgUrl = [aDict objectForKey:@"IMG_URL"];
NSString *aVideoUrl = [aDict objectForKey:@"VIDEO_URL"];
NSString *aAudioUrl = [aDict objectForKey:@"AUDIO_URL"];
NSArray *aPoemArrayUrls = [NSArray arrayWithObjects:aImgUrl,aVideoUrl,aAudioUrl,nil];
for(NSString* urlString in aPoemArrayUrls)
{
NSURL *url = [NSURL URLWithString:urlString];
ASIHTTPRequest *downloadAFileRequest = [[ASIHTTPRequest requestWithURL:url]retain];
NSString *Filename = [urlString lastPathComponent];
NSLog(@"%@ filename",Filename);
[downloadAFileRequest setUserInfo:[NSDictionary dictionaryWithObject:@"request1" forKey:@"name"]];
[downloadAFileRequest setDownloadDestinationPath:[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:Filename]];
[downloadAFileRequest setShouldContinueWhenAppEntersBackground:YES];
[downloadAFileRequest setDelegate:self];
[downloadAFileRequest setDidFinishSelector:@selector(requestDone:)];
[downloadAFileRequest setDidFailSelector:@selector(requestWentWrong:)];
[downloadAFileRequest setShowAccurateProgress:YES];
[self.networkQueue addOperation:downloadAFileRequest];
}
[self.networkQueue go];
}
}
셀에 직접 추가하는 나쁜 아이디어 [Cell.contentView addSubview : progress]; 재사용하면 논리가 깨질 것입니다. – NeverBe
동의하지 않았습니까? –