1

私は非常に単純な問題を理解するのに苦労しています。指を交差させれば、誰かが私の間違いを特定したり、より良いアプローチを提案したりできるでしょう。

私がやろうとしているのは、配列から多数の URL を取得し、各エントリに対して非同期の画像リクエストを開始することです。これらのリクエストは UIView オブジェクトを返します。これらを別の配列に追加して、後でアプリで使用できるようにします。

それは機能していません。私の問題は、ループが AsyncImageView を初期化する方法、新しい配列への割り当て、およびその後の初期化に関連していると推測しています。

for (iccAssociatedMediaObject *media in self.mediaArray) {
    if ( [media.usage isEqualToString:@"360"]) {

        // >> Here we have the array entry we need this is a URL string
        NSLog(@"URL : %@", media.href);

        // >> Next I start an Async load of the images, a UIView is returned/created...
        HJManagedImageV *asyncImageView = [[HJManagedImageV alloc] initWithFrame:CGRectMake(0, 0, 620, 620)];
        [asyncImageView setBackgroundColor:[UIColor grayColor]];
        [asyncImageView showLoadingWheel];
        [asyncImageView setContentMode:UIViewContentModeScaleAspectFill];
        [asyncImageView.imageView setContentMode:UIViewContentModeScaleAspectFill];
        asyncImageView.url = [NSURL URLWithString:media.href];
        // asyncImageView.callbackOnSetImage = (id)self;

        // >> Next I add the UIView (asyncImageView) to an array for use later in the app
        [objMan manage:asyncImageView];

        // >> I think my problem relates to the HJManagedImageV initialization & reuse?????
    }
}
4

1 に答える 1

0

For-Inループの外側に割り当ててから、ループを通過するたびに再利用してリセットしてみませんか?

于 2012-07-07T10:51:19.773 に答える