外部デリゲート コントローラーを持つテーブル ビューを作成していますが、ストーリーボードではなくコードで作成されています。セルに問題があります。実行がデリゲート メソッドに正しく到達しているにもかかわらず、セルが表示されません。
ビルド方法:
-(void)buildCategorias{
CGRect twitterFrame = CGRectMake(105, 83, 600, 568);
categoriasView = [[UIView alloc] initWithFrame:twitterFrame];
CGRect scrollViewFrame = CGRectMake(105, 83, 400, 568);
categoriasTableView = [[UITableView alloc] initWithFrame:scrollViewFrame];
categoriasController = [[categoriasViewController alloc] init];
categoriasController.categorias = [[NSArray alloc] initWithObjects:@"Gafas", @"Relojes", @"Pantalones", @"Deportivas", @"Cazadoras", nil];
[categoriasTableView setDelegate:categoriasController];
[categoriasTableView setDataSource:categoriasController];
[self.categoriasView addSubview:categoriasTableView];
[categoriasTableView reloadData];
[self.view addSubview:categoriasView];
}
カスタム セル: categoriasCell.h
@interface categoriasCell : UITableViewCell{
UILabel *title;
}
@property (nonatomic, strong) IBOutlet UILabel *title;
@end
カテゴリCell.m
@implementation categoriasCell
@synthesize title;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}
テーブル ビュー デリゲート:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
categoriasCell *cell = [self.tableView
dequeueReusableCellWithIdentifier:@"categorias"];
if (cell == nil) {
cell = [[categoriasCell alloc] initWithStyle:UITableViewCellSelectionStyleNone reuseIdentifier:@"categorias"];
}
cell.title.text = [categorias objectAtIndex:indexPath.row];
return cell;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
#warning Potentially incomplete method implementation.
// Return the number of sections.
return 1;
}
@end
テーブル ビューは空で、コンテンツはありません。
助けてくれて本当にありがとうございます