我正在尝试从我的touchesEnded处理程序中发送一个参数,如下所示...
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint currentPosition = [touch locationInView:self.view];
CGFloat deltaX = fabsf(gestureStartPoint.x - currentPosition.x);
CGFloat deltaY = fabsf(gestureStartPoint.y - currentPosition.y);
if (deltaX >= 0.3 && deltaY <= 100) { //horizontal swipe detected
[self performSelector:@selector(refreshCover:)
withObject:nil afterDelay:0];
if (gestureStartPoint.x < currentPosition.x) { //swipe right
[self refreshCover:@"backward"];
NSLog(@"swipe backward");
} else { //swipe left
[self refreshCover:@"forward"];
NSLog(@"swipe forward");
}
}
}然后在refreshCover中,我只需要:
- (void)refreshCover:(NSString*)direction {
NSLog(@"direction: %@", direction);
}当用户滑动时,会调用refreshCover,但不会传递direction参数。如果我从其他任何地方调用self refreshCover:@"forward“,参数传递都没有问题。
有什么想法吗?提前谢谢。
发布于 2011-02-03 12:01:15
问题出在下面的代码中
[self performSelector:@selector(refreshCover:)
withObject:nil afterDelay:0];performSelector将调用该函数。我认为这段代码是不需要的,因为您是单独调用该函数的
https://stackoverflow.com/questions/4882499
复制相似问题