Я пытаюсь создать свою собственную ячейку, но по какой-то причине она не появляется.Я прочитал много примеров, код выглядит (по крайней мере для меня) равным другим.Я использовал интерфейсный конструктор, чтобы воссоздать его (я удалил представление по умолчанию, добавил TableViewCell, поместил Identifier = CustomCell и связал метку с valueLabel).
Может ли кто-нибудь мне помочь?
Заранее спасибо.
//CustomCell.h
#import <UIKit/UIKit.h>
@interface CustomCell : UITableViewCell {
IBOutlet UILabel *valueLabel;
}
@property(nonatomic, retain) IBOutlet UILabel *valueLabel;
@end
//CustomCell.C
#import "CustomCell.h"
@implementation CustomCell
@synthesize valueLabel;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) {
// Initialization code
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
- (void)dealloc {
[super dealloc];
}
@end
//Where I'm trying to use this cell. Here I imported the .h file (#import "CustomCell.h"):
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"CustomCell";
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
cell = [[[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.valueLabel.text = @"Any text";
return cell;
}