0
我創建了一個自定義的UITableViewCell三的UILabel和一個的UIImageView, 1:我創建了子類的UITableViewCell的, 2:添加了三個標籤,一個的UIImageView,也是在廈門國際銀行文件 3:用以下方式的cellForRowAtIndexPath怎麼也得從筆尖自定義的UITableViewCell可重複使用
static NSString *CellIdentifier = @"NarrativeCell";
NarrativeCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil){
NSLog(@"New Cell Made");
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"NarrativeCell" owner:nil options:nil];
for(id currentObject in topLevelObjects)
{
if([currentObject isKindOfClass:[NarrativeCell class]])
{
cell = (NarrativeCell *)currentObject;
break;
}
}
}
Narrative n=(Narrative*)[tableArray objectAtIndexPath:indexpath.row];
[cell.articleName setText:n.title];
NSData *data=[[NSData alloc]initWithContentsOfFile:n.file]
[cell.sideImageView setImage:[UIImage imageWithData:data]];
問題創建細胞是這樣的,它總是會創建新的細胞和我添加一些圖片後,讓內存警告和崩潰。 請幫助如何可以重用上面代碼的單元格,以便它不應該使用多少內存
欺騙×2 http://stackoverflow.com/questions/540345/how-do-you-load-custom-uitableviewcells-from-xib-files http://stackoverflow.com/questions/413993/loading-a -reusable-的UITableViewCell-從-A-筆尖 –