- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
PostCount *post=[listArr objectAtIndex:indexPath.row];
//NSString *CellIdentifier = [NSString stringWithFormat: @"Cell%d_%d_%@_%d",indexPath.section,indexPath.row,post.foreignId,[listArr count]];
NSString *CellIdentifier = [NSString stringWithFormat: @"Cell_%d_%@",indexPath.row,post.foreignId];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
NSLog(@"indexPath.row++++++++=%d",indexPath.row);
TimeLineGraphicView *gview=[[TimeLineGraphicView alloc]init];
gview.tag=indexPath.row+1000;
gview.delegate=self;
[cell addSubview:gview];
int Allheight =[ModelClass returnGraphicViewHeight_timeLine:post];
gview.frame=CGRectMake(0, 0, 320, Allheight);
[gview setViewStyle:post];
}
TimeLineGraphicView *gview=(TimeLineGraphicView *)[cell viewWithTag:indexPath.row+1000];
gview.lab_time.text=[ModelClass intervalSinceNow:post.when btime:0];
//NSLog(@"intervalSinceNow=%@ ",[ModelClass intervalSinceNow:post.when btime:0]);
//NSLog(@"post.when=%@ gview=%@ gview.lab_time.text=%@",post.when,gview, gview.lab_time.text);
return cell;
}
你好,如果我使用上面的代碼,如果我有許多細胞,TimeLineGraphicView * gview = [[TimeLineGraphicView的alloc] INIT]可以增加存儲器,因爲當我首先加載許多細胞例如我加載15細胞,然後加入15細胞,然後加入15電池等,它給我didReceiveMemoryWarning,你能很好的做法來處理這個問題的UITableView負載許多細胞和MemoryWarning
好吧,那麼你不會發布'TimeLineGraphicView'。 : -/ – 2013-02-26 09:10:01
我使用ARC,如何發佈 – pengwang 2013-02-26 09:13:14
您並未重複使用已經創建的單元。每次你爲所有的indexpath創建新的單元格。所以如果你有1000個單元格,你正在創建1000個不同的單元格。 – Exploring 2013-02-26 09:20:03