UITableViewCell を拡張するカスタム クラスがあります。2 つのラベルと UISegmentedControl があります。
これが、構成した cellForRowAtIndexPath() です。デバッガーで「セル」を調べると、提供しているすべてのデータが含まれています。しかし、どういうわけか、そのデータは決して適用されません。
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"MyCell";
CustomGameCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[CustomGameCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
MyData *my_data = [rows objectAtIndex:indexPath.row];
UILabel *my_date = [[UILabel alloc] init];
my_date.text = my_data.myDate;
[cell setMyDateLabel:my_date];
UILabel *my_question = [[UILabel alloc] init];
my_question.text = my.question;
[cell setMyQuestionLabel:my_question];
UISegmentedControl *my_choices = [[UISegmentedControl alloc]
initWithItems:[NSArray arrayWithObjects:my.firstChoice, my.secondChoice, nil]];
[my_choices setSelectedSegmentIndex:my.choice];
[cell setMyChoiceSegments:my_choices];
return cell
}
表示したいデータは現在、viewDidLoad() で作成した配列にあり、「rows」変数を介して cellForRowAtIndexPath() にアクセスできます。
シミュレーターでコードを実行すると、viewDidLoad() で作成した配列の 3 つの要素を表すテーブルに 3 つの行が表示されます。ただし、これらの行の内容は、ストーリーボードで定義したものとまったく同じように見えます。
私は何が欠けていますか?