メインテーブルビューのカスタムセルを作成することにより、テーブルビューの各セルにテーブルビューがあります。問題は、最初のものを除くすべてのインデックスパスのテーブルビュー コンテンツを表示できることです。テーブルビューをスクロールして最初のセルを画面外に出し、最初のセルをスクロールして戻すと、最初のセルのコンテンツが表示されます。
以下の私のコードを見つけてください
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [itemArray count];
}
- (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.lineBreakMode = UILineBreakModeWordWrap;
cell.textLabel.numberOfLines = 0;
cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:17.0];
}
for (int i=0; i<[itemArray count]; i++) {
////NSLog(@"row is %d",i);
if (indexPath.row==i) {
cell.textLabel.text=[itemArray objectAtIndex:i];
}
}
return cell;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
なぜそれが起こっているのか誰にも教えてもらえますか。最初のセルの内容も画面に表示したい。