我已经自定义了表格视图单元格,创建了 nib 文件及其对应的 .h 和 .m 文件。一切正常,除了滚动时的缓慢,我怎样才能避免冻结可能是什么问题?
和
obj = [self.listData objectAtIndex: [indexPath row]];
if (obj != nil) {
static NSString *CellIdentifier;
if (obj->status == status1) {
CellIdentifier = @"Cell_italic";
} else if (obj->status == status2) {
CellIdentifier = @"Cell_cent";
} else {
CellIdentifier = @"Cell";
}
custom_cell *cell = (custom_cell*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"custom_cell" owner:self options:nil];
cell = [nib objectAtIndex:0];
char file_path[MAX_PATH]; // Holds file path.
memset(file_path, 0, MAX_PATH);
// Get path
// Set Image
UIImage *cellImage = [UIImage imageWithContentsOfFile:fle_path];
if (cellImage != nil) {
[cell.image_view setImage:cellImage];
}
NSString *combined_name = [NSString stringWithCString:obj->combined_name encoding:NSASCIIStringEncoding];
NSString *email = [NSString stringWithCString:obj->email encoding:NSASCIIStringEncoding];
// Set name
if (obj->status == status1)
{
cell.name_label.text = combined_name;
cell.name_label.font = [UIFont fontWithName:@"Georgia-Italic" size:18];
cell.email_label.text = email;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
. . .
. . .
}
dequeueReusableCellWithIdentifier 总是返回 nil,对吗?如果没有自定义,我已经多次看到它不是 nil,现在它总是返回 nil。