문제

In my view, I have two steppers that are both linked to this function

- (IBAction)stepperChanged:(UIStepper *)sender {
    int value = [sender value];

    printf("value: %d", value);
}

Is there a quick and easy way to identify which stepper triggered this event?

도움이 되었습니까?

해결책

Give the stepper a tag and then check the value of the tag. You can set a tag in code or in IB.

다른 팁

You can also declare a property as well, which I like more than tags myself:

@property (nonatomic, strong) UIStepper *stepper1;

- (IBAction)stepperChanged:(UIStepper *)sender 
{
    if (sender == self.stepper1)
    {
        NSLog(@"Value of stepper1 is: %d",sender.value);
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top