title: iOS: UIStepper within UITableView Cells
body: <p>I never really had the need to use <code>UIStepper</code>, so I thought I would try it.</p>
  
  <p>And I tried it within table cells. The following is my code:</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      static NSString *CellIdentifier = @"Cell";
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  
      UIStepper *stepper = [[UIStepper alloc] initWithFrame:(CGRect){{40, 40}, 20, 20}];
      [stepper addTarget:self action:@selector(stepperTapped:) forControlEvents:UIControlEventValueChanged];
      stepper.tag = indexPath.row;
      stepper.stepValue = 1;
      stepper.continuous = YES;
      stepper.minimumValue = 0;
      stepper.maximumValue = 10;
      [cell.contentView addSubview:stepper];
  
      return cell;
  }
  </code></pre>
  
  <p>Action method:</p>
  
  <pre><code>- (void)stepperTapped:(UIStepper*)stepper
  {
      NSLog(@"sender tag: %li", (long)stepper.tag);
  
      UITableViewCell *currentCell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:stepper.tag inSection:0]];
      NSNumber *stepperValue = [NSNumber numberWithDouble:stepper.value];
      currentCell.textLabel.text = [NSString stringWithFormat:@"%f", stepper.value];
      [self.tableView reloadData];
  }
  </code></pre>
  
  <p>Am just testing it with 4 cells and 1 section.</p>
  
  <p>It runs, but the stepper only increments once (0 -> 1 or 1 -> 0), it won't go up until 10, which is the maximum number I set.</p>
  
  <p>I tested the same code not within table cell and it works fine. From 0 to 10, and from 10 to 0, each step.</p>
  
  <p>This little experiment has cost me 2 hours trying to find a solution.</p>
  
  <p>Can anyone spot the problem here?</p>