uitabletecell中的UIStepper

Dmi*_*iuk 2 iphone objective-c uitableview ios uistepper

在我的应用我有自定义UITableViewCell,我有UIStepperUILabel自定义单元格.我不知道如何检查单击哪个步进器.那么它是一种了解单击哪个单元步进器的方法吗?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell;
    NSString *CellIdentifier = @"Cell";
    cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
        if ([nib count] > 0) {
            cell = self.tbcell;
        }
    }
    return cell;
}
Run Code Online (Sandbox Code Playgroud)

Can*_*pus 7

另一种选择是:

在UIStepper值更改时触发的方法(例如@max_,上面),您可以执行以下操作:

- (IBAction)stepperValueDidChanged:(UIStepper *)sender {
    UITableViewCell *cell = (UITableViewCell *)[[sender superview] superview];
    // assuming your view controller is a subclass of UITableViewController, for example.
    NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
}
Run Code Online (Sandbox Code Playgroud)