私はUITableViewで動的データを表示していますその中のチェックボックスボタン。ユーザーがチェックボックスボタンを選択すると、そのすぐ下にUIStepperが表示されます。私はこれを達成する方法を知らない、私が正確に必要なことは以下のURLに記載されています。 目標達成
UITableViewにデータを表示しました以下のコードに記載されているとおり。ユーザーがチェックボックスを選択したときにすべてのインデックスの下にセルを追加するか、従うべき他の良いアプローチがあるかどうか、これを達成する方法がわかりません。
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [getNutrients count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"NutrientCell";
UITableViewCell *nutrientCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
nutrientCell.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"texture_bg.png"]];
UILabel *nutrientLabel = (UILabel*)[nutrientCell viewWithTag:1];
nutrientLabel.text = [[getNutrients objectAtIndex:indexPath.row]valueForKey:@"name"];
return nutrientCell;
}
回答:
回答№1は0UITableViewには、行またはセクションを挿入するプロパティがあります。 insertRowsAtIndexPaths:withRowAnimationを使用できます。 deleteRowsAtIndexPaths:withRowAnimation: それぞれ行の挿入および削除用。