我正在使用带有步进器和标签的自定义表格视图单元格。但是当我检查步进器的值时,它每 2 次按下只会增加一次。问题是什么?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"cellData";
ItemCell *cell = [self.myTableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil)
{
cell = [[ItemCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
cell.stepper.tag = indexPath.row;
cell.countLabel.text = [NSString stringWithFormat:@"%g",cell.stepper.value];
NSLog(@"value = %g",cell.stepper.value);
cell.itemLabel.text = [self.groceryItems objectAtIndex:indexPath.row];
return cell;
}
- (IBAction)valueChanged:(id)sender
{
UIStepper *step = sender;
NSIndexPath *index = [NSIndexPath indexPathForRow:step.tag inSection:0];
NSArray *rowsToReload = [NSArray arrayWithObject:index];
[self.myTableView reloadRowsAtIndexPaths:rowsToReload withRowAnimation:NO];
}