문제

내가 사용하고 싶 ASIHttprequest 라이브러리를 일부 파일을 다운로드,저는 테스트를 자신의 코드고 그것은 작동하지 않는 동안 동일한 코드를 사용할 수 있습니에서 자신의 샘플

이것은 나의 코드를 호출하 보기

QueueViewController *queueViewController=[[QueueViewController alloc] initWithNibName:@"큐"뭉치:nil];[자기.보기 addSubview:queueViewController.보기];

이 코드를 요청

- (IBAction)fetchThreeImages:(id)sender
{
    [imageView1 setImage:nil];
    [imageView2 setImage:nil];
    [imageView3 setImage:nil];

    [networkQueue cancelAllOperations];
    [networkQueue setDownloadProgressDelegate:progressIndicator];
    [networkQueue setRequestDidFinishSelector:@selector(imageFetchComplete:)];
    [networkQueue setShowAccurateProgress:[accurateProgress isOn]];
    [networkQueue setDelegate:self];

    ASIHTTPRequest *request;
    request = [[[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:@"http://allseeing-i.com/i/logo.png"]] autorelease];
    [networkQueue addOperation:request];

    request = [[[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:@"http://allseeing-i.com/i/trailsnetwork.png"]] autorelease];
    [networkQueue addOperation:request];

    request = [[[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:@"http://allseeing-i.com/i/sharedspace20.png"]] autorelease];
    [networkQueue addOperation:request];

    [networkQueue go];

}


- (void)imageFetchComplete:(ASIHTTPRequest *)request
{
    UIImage *img = [UIImage imageWithData:[request responseData]];
    if (img) {
        if ([imageView1 image]) {
            if ([imageView2 image]) {
                [imageView3 setImage:img];
            } else {
                [imageView2 setImage:img];
            }
        } else {
            [imageView1 setImage:img];
        }
    }
}

그것처럼 보이는 큐를 설정이 제대로 하지만 imageFetchComplete 방법은 사용하지 않는 경우 다운로드이 수행됩니다.

도움이 되었습니까?

해결책 2

나는 문제를 해결했는데, 문제는 제가 올 로코 네트워크 queue가 아니라는 것입니다.

나는 호출되지 않은 awakefromnib에서 동반 네트워크 큐였습니다. 버튼 클릭 메소드에 네트워크 큐를 할당합니다. 문제가 해결되었습니다.

다른 팁

도 설정 requestDidFailSelector 에 귀하의 인스턴스 ASINetworkQueue, 뿐만 아니라 설정 didFinishSelectordidFailSelector 에 각각의 인스턴스 ASIHTTPRequest.전화 NSLog()에서 각 사람들의 콜백 방법에 대해서는 총 요금을 지불하셔야 합니다.

참고는여 showAccurateProgressASINetworkQueue, 추가 HEAD 요청을 수행하는 모든 요청에 대해 큐 프로세스입니다.이는 때때로 보다 이상적인 모바일 context.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top