2012-07-07 42 views
1

我努力让自己的脑袋围绕什么应该是一个非常简单的问题,手指穿过别人将能够识别我的错误或提出更好的方法。多个异步图像请求和任务分配给NSArray

我想要做的是从数组中检索一些URL,然后为每个条目启动一个异步映像请求。这些请求将返回一个UIView对象,然后将这些请求添加到另一个数组中以供稍后在应用程序中使用。

它不工作,我猜我的问题涉及到环路初始化的AsyncImageView,分配到新阵列,然后进一步initialisations的方式。

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????? 
    } 
} 

回答

0

为什么不for-in循环,然后就再使用分配外,并重置它每次通过循环?

+0

感谢您的建议,我遇到的问题是由于该项目有多个HJCache实例。 – 2012-07-19 15:31:06