初学IOS,在学习自定义cell的时候遇到这么一个问题:
- (void)viewDidLoad {
NSString * identifier = @"TableViewCell";
[tableview registerClass:[TableViewCell class] forCellReuseIdentifier:identifier];
}
在
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
//第一种这种方式是可以的
// BOOL noRegistered = NO;
// if(!noRegistered){
// UINib *nibOther = [UINib nibWithNibName:NSStringFromClass([TableViewCell class]) bundle:nil];
// [tableView registerNib:nibOther forCellReuseIdentifier:NSStringFromClass([TableViewCell class])];
// noRegistered = YES;
// }
// TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([TableViewCell class])];
//为什么这种方式,cell的内容就不显示呢?
NSString * identifier =
- (void)viewDidLoad {
NSString * identifier = @"TableViewCell";
[tableview registerClass:[TableViewCell class] forCellReuseIdentifier:identifier];
}
在
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
//第一种这种方式是可以的
// BOOL noRegistered = NO;
// if(!noRegistered){
// UINib *nibOther = [UINib nibWithNibName:NSStringFromClass([TableViewCell class]) bundle:nil];
// [tableView registerNib:nibOther forCellReuseIdentifier:NSStringFromClass([TableViewCell class])];
// noRegistered = YES;
// }
// TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([TableViewCell class])];
//为什么这种方式,cell的内容就不显示呢?
NSString * identifier =