我有一个IBAction:
- (IBAction)stop:(id)sender {
NSLog(@"Called");
if (timer) {
[timer invalidate];
timer = nil;
}
}这应该会停止正在运行的计时器,我已经包含了NSLog,以查看我对计时器的无效是错误的,还是方法甚至没有被调用,并且它没有被调用。我有我的按钮连接到“触摸取消”方法在故事板,有什么我可以做的工作吗?另外,我有一个"Touch Down“方法来启动计时器:
- (IBAction)begin:(id)sender {
[timer invalidate];
timer = [NSTimer scheduledTimerWithTimeInterval:0.25 target:self selector:@selector(doSomething:) userInfo:nil repeats:YES];
}发布于 2014-06-06 00:44:51
若要在按下和释放UIButton时关闭IBAction,您需要使用"Touch Up it“发送事件,而不是"Touch Cancel”。
https://stackoverflow.com/questions/24072355
复制相似问题