私はtableViewに6行のテキストを表示させたいとします。私が知る限り、numberOfSectionsInTableView:
とnumberOfRowsInSection:
が正しく設定されています。以下のサンプルコードを参照してください:UITableViewがnumberOfRowsInSectionで指定された数よりも多くの行を表示しています:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
// Return the number of rows in the section.
return 6;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = @"Example";
return cell;
}
問題は、存在しない/存在してはいけない行の行を示しています。私は過去6行目を示すラインを取り除くにはどうすればよい
?
これは、スクロールするために必要とされるよりも少ない行を持つすべてのプレーンテーブルビューのデフォルトの動作です、行とセクションの数を設定するだけでは役に立ちません。あなたは別の方法を見つける必要があります... – BoltClock