我已经通过所有相关的问题,看了看,我仍然不能得到这个工作。自定义标签不显示在自定义单元格中。故事板
我做了一个自定义单元格的.xib(foodCell.xib),并设置它的文件所有者foodCell.h。我还将标识符设置为foodCell。
到目前为止,所有我在自定义单元格是一个自定义标签 - priceLabel
。我遇到的问题是我似乎无法为自定义标签设置值或在运行时显示它。
这里是我的foodcell.h文件:
#import <Parse/Parse.h>
@interface foodCell : PFTableViewCell
@property (weak, nonatomic) IBOutlet NSObject *foodCell;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
@end
这里是我的tableViewController文件I配置自定义单元格。所有其他label.text调用都可以正常工作,并显示图像。
我NSLOG
调用返回null
。
为什么我不能设置或显示这个自定义标签?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object {
static NSString *CellIdentifier = @"foodCell";
foodCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[foodCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
// Configure the cell
cell.textLabel.text = [object objectForKey:@"foodName"];
cell.detailTextLabel.text = [object objectForKey:@"foodDescription"];
cell.imageView.file = [object objectForKey:@"foodImage"];
NSString *myString = @"TEST";
cell.priceLabel.text = myString; //[object objectForKey:@"foodPrice"];
NSLog(cell.priceLabel.text);
cell.detailTextLabel.numberOfLines=0; // line wrap
cell.detailTextLabel.autoresizingMask = UIViewAutoresizingFlexibleHeight;
return cell;
}
如果你记录cell.priceLabel你会得到什么? – sha
你注册了的tableView你的笔尖? –