コードのみを使用して(IBを使用せずに)UIViewでUITableViewを作成します
m_tableData = [[UITableView alloc] init];
m_tableData.dataSource = self;
m_tableData.delegate = self;
[self addSubview:m_tableData];
と
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSLog(@"%d", [arrPanelListImg count]);
return [arrPanelListImg count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"kCell"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"kCell"] ;
NSLog(@"%d", indexPath.row);
}
return cell;
}
そして、ログ画面に表示されます
numberOfRowsInSection:メソッドは18を返します。cellForRowAtIndexPath:メソッドは、9回実行するだけです(画面に収まります)。
そして、私は自分のコードに何も奇妙なことを発見しませんでした。したがって、この場合、誰かが私に何か提案をします。よろしくお願いします。