我以前使用过UItableViewCell
默认标题和详细信息标签,它工作正常,没有任何警告,现在我已经自定义了表格视图单元格,我已经使用标签并添加为子视图,并且我也从文件中获取图像用于联系人......现在我我经常收到内存警告并且它正在崩溃,我正在重用如下所示的标识符仍然出现警告.. 可能是什么问题,我是否没有正确释放标签的内存或经常从文件中获取图像,导致这种情况?任何想法...
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
// Get the path of the file.
get__path(file_path);
NSString *fle_path = [NSString stringWithUTF8String:file_path];
fle_path = [fle_path stringByAppendingFormat:@"%c%ld%s",'/',obj->user_id,".jpg" ];
NSString *combined_name = [NSString stringWithCString:obj->combined_name encoding:NSASCIIStringEncoding];
NSString *email = [NSString stringWithCString:obj->email encoding:NSASCIIStringEncoding];
CGRect rect = [cell frame];
UIImageView *img_view = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 55, 55)];
UILabel *name_label = [[UILabel alloc] initWithFrame:CGRectMake(60, 7, rect.size.width-70, 20)];
UILabel *detail_label = [[UILabel alloc] initWithFrame:CGRectMake(60, 27, rect.size.width-70, 20)];
// Set Image
UIImage *cellImage = [UIImage imageWithContentsOfFile:fle_path];
if (cellImage != nil) {
[img_view setImage:cellImage];
}
// Set name
[detail_label setFrame:CGRectMake(60, 18,rect.size.width-70, 20)];
name_label.text = combined_name;
name_label.font = [UIFont fontWithName:@"Georgia-Italic" size:18];
detail_label.text = email;
[cell_italic.contentView addSubview:img_view];
[cell_italic.contentView addSubview:detail_label];
cell_italic.selectionStyle = UITableViewCellSelectionStyleNone;
rect.size.height = 55;
[cell_italic setFrame:rect];
return cell_italic;
我什么时候应该释放上述标签的内存......?