Iphone TableView不会显示单元格内容
我有一个TableViewCell子类,我正在尝试创建一个具有此单元格类型的表。但是,该表不会显示自定义单元格内容。 单元的值源自数据核心模型。但它没有问题,因为我也尝试过使用简单的文本,但仍然不起作用。感谢您的帮助 这是我的密码: 费塞尔 favTable.mIphone TableView不会显示单元格内容,iphone,xcode,uitableview,Iphone,Xcode,Uitableview,我有一个TableViewCell子类,我正在尝试创建一个具有此单元格类型的表。但是,该表不会显示自定义单元格内容。 单元的值源自数据核心模型。但它没有问题,因为我也尝试过使用简单的文本,但仍然不起作用。感谢您的帮助 这是我的密码: 费塞尔 favTable.m 此[UITableViewCell namelbl]:发送到实例的无法识别的选择器表示您正在使用的单元格是普通UITableViewCell实例,而不是favCell。在表格设计的某些地方,您没有设置正确的单元格类型或标识符。@Phil
此[UITableViewCell namelbl]:发送到实例的无法识别的选择器表示您正在使用的单元格是普通UITableViewCell实例,而不是favCell。在表格设计的某些地方,您没有设置正确的单元格类型或标识符。@PhillipMills是的,您是对的。只是把我的原型单元的类改成了自定义的子类。但是,使用[self.contentView addSubview:view]时,单元格的内容仍然不会显示出来;代替[自添加子视图:视图]@学生不,没有区别,在CellForRowatineXpath中设置一个断点,然后查看您分配的值和对象。
#import "favCell.h"
@implementation favCell
@synthesize view;
@synthesize namelbl;
@synthesize scorelbl;
@synthesize prodimage;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
view = [[UIView alloc] initWithFrame:self.frame];
[self addSubview:view];
// initiate
prodimage = [[UIImageView alloc]initWithFrame:CGRectMake(2,20, 20, 20)];
namelbl = [[UILabel alloc]initWithFrame:CGRectMake(3,20, 40, 40)];
scorelbl = [[UILabel alloc]initWithFrame:CGRectMake(70,20, 30, 30)];
[view addSubview:namelbl];
[view addSubview:scorelbl];
[view addSubview:prodimage];
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
#import "favTable.h"
#import "ecoAppDelegate.h"
#import "favCell.h"
@interface favTable ()
@end
@implementation favTable
@synthesize favArr;
@synthesize managedObjectContext;
@synthesize fetchedResultsController;
@synthesize favName;
@synthesize favScore;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
favCell*cell = (favCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[favCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.namelbl.text = [favName objectAtIndex:indexPath.row];
cell.scorelbl.text = [favScore objectAtIndex:indexPath.row];
cell.prodimage.image = [UIImage imageNamed:@"test1.jpg"];
return cell;
}