【问题标题】:IOS - Add Cells at particular index with uistepperIOS - 使用 uistepper 在特定索引处添加单元格
【发布时间】:2016-06-24 02:48:22
【问题描述】:

我在 UITableView 中显示动态数据,其中包含复选框按钮。当用户选择复选框按钮时,它将在其下方显示 UIStepper。我不知道如何实现这一点,下面的网址中提到了我的确切要求。 Target To achieve

我刚刚在 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;
}

【问题讨论】:

    标签: ios objective-c uitableview autolayout storyboard


    【解决方案1】:

    UITableView 具有插入行或节的属性。 您可以使用 insertRowsAtIndexPaths:withRowAnimation: deleteRowsAtIndexPaths:withRowAnimation: 分别用于插入和删除行。

    【讨论】:

      猜你喜欢
      • 2016-03-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多