0

私は目的の c が初めてで、uitableview を理解しようとしています。テーブルビューに 2 つのセルを追加しました。テーブルビューの任意の領域をクリックすると、2 つのセルが消えるか、ラベルが削除されます。私はわかりません。どうすればこれを修正できますか?

これが2つのセルを追加する方法です

- (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];
}

if(indexPath.row==0)
    cell.textLabel.text=@"test 1";
else if (indexPath.row==1)
    cell.textLabel.text=@"test 2";
// Configure the cell...

return cell;
}

 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
 { 
  return 1;
  }

 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
 {
  return 5;
 }

セクションと行を指定しました

4

1 に答える 1