我尝试了许多不同的方式在我的tableview中定制单元格,但没有任何工作。我也尝试过有一个UITableViewCell的子类,但它也没有工作。dequeueReusableCellWithIdentifier:引发异常
所以,我回到了一个更简单的解决方案。
我已在TableView中内部的原型细胞 - 这是被类的UITableViewCell的具有标识符:LocalPostsCell
我的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [self.postsTable dequeueReusableCellWithIdentifier:@"LocalPostsCell" ];
// ... blah blah get values for name/text variables
UILabel *nameLabel = (UILabel *)[cell viewWithTag:100];
UILabel *descriptionLabel = (UILabel *)[cell viewWithTag:101];
if (name == nil || [name isEqual:[NSNull null]]) {
// handle the place not being available
nameLabel.text= @"";
} else {
nameLabel.text = name;
}
if (text == nil || [text isEqual:[NSNull null]]) {
// handle the place not being available
descriptionLabel.text = @"";
} else {
descriptionLabel.text = text;
}
return cell;
}
我还试图这样:
UITableViewCell *cell = [self.postsTable dequeueReusableCellWithIdentifier:@"LocalPostsCell" forIndexPath:indexPath];
所有这些都在此行失败,除了(lldb) - 线程1 - 断点1.1错误外,控制台中没有任何内容被打印。
我为所有异常添加了断点,并启用了僵尸功能。