ios 自定义cell中怎么让代码只初始化一次

2025-03-21 22:29:11
推荐回答(1个)
回答1:

先判断cell是否为空,如果不为空就创建不就是一次吗》
static NSString *cellID = @"cellID";
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellID];
if(!cell)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
}