-5

运行上述函数时的错误日志:

2013-06-28 21:10:32.435 B3 Controller[68665:c07] Logged knob : 1
2013-06-28 21:10:32.436 B3 Controller[68665:c07] -[ViewController rotaryKnobDidChange]: unrecognized selector sent to instance 0x71721f0
2013-06-28 21:10:32.437 B3 Controller[68665:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ViewController rotaryKnobDidChange]: unrecognized selector sent to instance 0x71721f0'

谢谢你帮助我。

这是代码:

... - (IBAction)rotaryKnobDidChange:(id)sender;

- (IBAction)rotaryKnobDidChange:(RotaryKnob*)sender
{
    NSLog(@"Logged knob : %ld",(long)(sender.tag));
    switch(sender.tag)
    {
        case 0:
            self.driveLabel.text = [NSString stringWithFormat:@"%.0f%%", self.DriveKnob.value*100];
            break;
        case 1:
            self.edgeLabel.text = [NSString stringWithFormat:@"%.0f%%", self.EdgeKnob.value*100];
            break;
        case 2:
            self.reverbLabel.text = [NSString stringWithFormat:@"%.0f%%", self.ReverbKnob.value*100];
            break;
    }
}
4

1 回答 1

2

根据这个错误,某个地方的某个人正在尝试调用[viewController rotaryKnobDidChange]而不是[viewController rotaryKnobDidChange:self]. 冒号是名称的一部分——你不能省略它——而且参数不是可选的。

于 2013-06-28T19:31:24.047 回答