我的tableviews和线程数据存在问题。在我的应用程序中我下载xml中的数据,包括一个图像网址,然后解析,以获取我的tableviews的图像。
即时通讯使用asyncimageview类(markj.net)。如果我线程下载我的xml,那么realoadData单元格显示正常,appart形式图像永远不会加载,直到它们出列并重新加载,我不知道如何解决它。
请帮助.....
答案 0 :(得分:0)
好的,我设法使用此
修复它- (void)loadImagesForVisibleCells;
{ NSArray cells = [self.newsStories visibleCells]; [细胞保留]; for(int i = 0; i< [cells count]; i ++) { //遍历数组中的每个单元格并调用其loadContent方法(如果它响应它)。 CGRect框架; frame.size.width = 75; frame.size.height = 75; frame.origin.x = 0; frame.origin.y = 0; AsyncImageView asyncImage = [[[AsyncImageView alloc] initWithFrame:frame] autorelease];
//AsyncImageView *asyncImage = (AsyncImageView *)[[cells objectAtIndex: i] retain];
//*flickrCell = (FlickrCell *)[[cells objectAtIndex: i] retain];
NewcastleStories *aStory = [stories objectAtIndex:i];
//AsyncImageView* asyncImage = [[AsyncImageView alloc]init];
[asyncImage emptyImages];
NSURL* url =[NSURL URLWithString:aStory.picture];
[asyncImage loadImageFromURL:url];
//[cells objectAtIndex:i])
static NSString *CellIdentifier = @"ImageCell";
UITableViewCell *cell = [newsStories dequeueReusableCellWithIdentifier:CellIdentifier];
[cell.contentView addSubview:asyncImage];
[[self newsStories]setNeedsLayout];
[[self newsStories] setNeedsDisplay];
//[self dataLoaded];
//[asyncImage loadImage];
//[flickrCell release];
//flickrCell = nil;
}
[cells release];
}
但必须使用
在主线程中调用它[self performSelectorOnMainThread:@selector(loadImagesForVisibleCells) withObject:nil waitUntilDone:YES];