下面显示的是我用来创建单元格的代码。该单元未被重复使用。每次 cell==nil
变为真。
我在 xib 中正确设置了标识符。请帮助我。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
SRCourseListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if (cell == nil) {
NSArray *nib=[[NSBundle mainBundle]loadNibNamed:@"SRCourseListCell" owner:self options:nil];
cell=[nib objectAtIndex:0];
}
return cell;
}
最佳答案
在您的 SRCourseListCell 中,添加
- (NSString *) reuseIdentifier {
return @"cell";
}
或者(因为你正在使用 nibs 可能是更好的解决方案),设置 identifier to "cell" in the inspector .
关于ios - UITableViewcell 未重用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17761804/