it's working great with one UIButton:
– (void) viewDidLoad {
[super viewDidLoad];
CPBPressureTouchGestureRecognizer* recognizer = [[CPBPressureTouchGestureRecognizer alloc] initWithTarget:self action:@selector(A_button:)];
[A_button addGestureRecognizer: recognizer];
[recognizer release];
}
- (void) A_button: (CPBPressureTouchGestureRecognizer*) recognizer {
[pan_A setGain:recognizer.pressure];
[pan_A] play;
}
i tried to use more but only the second one is working:
- (void) viewDidLoad {
[super viewDidLoad];
CPBPressureTouchGestureRecognizer* recognizer1 = [[CPBPressureTouchGestureRecognizer alloc] initWithTarget:self action:@selector(A_button:)];
[A_button addGestureRecognizer: recognizer1];
CPBPressureTouchGestureRecognizer* recognizer2 = [[CPBPressureTouchGestureRecognizer alloc] initWithTarget:self action:@selector(B_button:)];
[B_button addGestureRecognizer: recognizer1];
[recognizer1 release];
[recognizer2 release];
}
- (void) A_button: (CPBPressureTouchGestureRecognizer*) recognizer1 {
[pan_A setGain:recognizer1.pressure];
[pan_A] play;
}
- (void) B_button: (CPBPressureTouchGestureRecognizer*) recognizer1 {
[pan_B setGain:recognizer2.pressure];
[pan_B] play;
}
how can i get both to work?
The CPBPressureTouchGestureRecognizer only supported a single instance of itself do to the delegate model of the UIAccelerometer. Here is a better version that supports multiple instances.