2

私のアプリには customUITableViewCellUIStepperありUILabel、カスタムセルには and があります。どのステッパーがクリックされたかを確認する方法がわかりません。それで、どのセルステッパーからクリックされたかを知る方法ですか?

- (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;
}
4

2 に答える 2

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];
}
于 2012-03-18T19:39:35.923 に答える
0
[step addTarget:self action:@selector(someAction:) forControlEvents:UIControlEventValueChanged];

- (void) someAction:(UIStepper *) stepper {
    NSLog(@"stepper clicked");
}
于 2012-03-18T19:15:53.103 に答える