【发布时间】:2012-02-22 21:45:29
【问题描述】:
我的代码:
-(void)viewDidLoad {
[super viewDidLoad];
CPBPressureTouchGestureRecognizer* recognizer = [[CPBPressureTouchGestureRecognizer alloc] initWithTarget:self action:@selector(A_button:)];
[A_button addGestureRecognizer: recognizer];
[recognizer release];
[P2_button addTarget:self action:@selector(touchUp:) forControlEvents:UIControlEventTouchUpInside];
[P2_button addTarget:self action:@selector(touchDown:) forControlEvents:UIControlEventTouchDown];
}
- (void) A_button: (CPBPressureTouchGestureRecognizer*) recognizer {
[self.presLabel setText:[NSString stringWithFormat:@"%f",recognizer.pressure]];
}
最后
-(IBAction)touchUp :(id)sender{
[myTimer invalidate];
myTimer = nil;
NSLog(@"up");
}
-(IBAction)touchDown :(id)sender{
myTimer = [NSTimer scheduledTimerWithTimeInterval:0.1
target:self
selector:@selector(A_button:)
userInfo:nil
repeats:YES];
}
但不工作,如果在计时器选择器中我写 @selector(A_button) 什么都不做,如果我写 @selector(A_button:) 返回错误:
2012-02-22 22:38:24.837 TestPres[19686:707] -[__NSCFTimer pressure]:无法识别的选择器发送到实例 0x143570 2012-02-22 22:38:24.847 TestPres[19686:707] * 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[__NSCFTimer 压力]:无法识别的选择器发送到实例 0x143570”
问题出在哪里?按下m键怎么能显示0.1秒的压力值?
谢谢
【问题讨论】:
标签: iphone xcode uibutton selector pressure