0

ここのコードhttps://stackoverflow.com/a/7212943/711837に従って、アプリが特定の Web サイトから画像をダウンロードしようとしているインジケーターを表示し始めました。シナリオは次のとおりです。

多くのカスタム セルを含むテーブルビューがあり、カスタム セルには 2 つのラベルとイメージビューがあります。ラベルNSURLを埋めるコンテンツをダウンロードしてから、画像をダウンロードしてUIImageView. スピナーと画像のダウンロードのコードは次のとおりです。

resultArray = [[NSArray alloc] initWithArray:response];
[self downloadImageFromInternet:@"http://static.colourlovers.com/images/shapes/0/7/7090/50x50.png"];
//spinner for the download
spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
spinner.frame = CGRectMake(0, 0, 24, 24);
custcell.accessoryView = spinner;
[spinner startAnimating];
///[spinner release];

[self.thetableView reloadData];

そして[spinner stopAnimating]、クラスの最後のダウンロードメソッドを呼び出しますが、どういうわけか、スピナーはアニメーション化されないか、問題として表示されません! 私は何かを逃していますか?または私が参照できる場所はありますか?私の目的は、ロード後にイメージビューが同じ位置を引き継ぎ、これがすべてのセルにUIIndicatorViewある場所を表示することです。UIImageView

更新されたメソッドが追加されました

-(void) downloadImageFromInternet:(NSString*)urlToImage{
    // Create a instance of InternetImage
    asynchImage = [[DownloadThumb alloc] initWithUrl:urlToImage];

    // Start downloading the image with self as delegate receiver
    [asynchImage downloadImage:self];
}

-(void) internetImageReady:(DownloadThumb*)downloadedImage{ 
    // The image has been downloaded. Put the image into the UIImageView
    [arrayImg addObject:downloadedImage.Image];
    [spinner stopAnimating];
    [self.thetableView reloadData];
}

-(void)downloadImage:(id)delegate{
m_Delegate = delegate;

NSURLRequest *imageRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:ImageUrl] 
                                              cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:60.0];
imageConnection = [[NSURLConnection alloc] initWithRequest:imageRequest delegate:self];

if(imageConnection)
{
    workInProgress = YES;
    m_ImageRequestData = [[NSMutableData data] retain];
}

}

4

1 に答える 1

0

セルを作成するときは、実際にスピナーを開始する必要があります。
次に、cellForRowAtIndexPath表示するかどうかをチェックインする必要があります。
最後に、表示する必要がある場合は、 を使用[tableView reloadData]して表示または削除できます。

于 2012-03-06T09:35:06.623 に答える