UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipedGesture:)];
swipe.direction = UISwipeGestureRecognizerDirectionRight;
swipe.numberOfTouchesRequired = 1;
[self.myLabel.superview addGestureRecognizer:swipe];
- (void)swipedGesture:(UIGestureRecognizer *)recognizer
{
NSLog(@"I swiped ;)");
}
所以,这是发生了什么事情:我有一个名为myLabel
的标签。当我向右滑动时,它应该打印NSLog
I swiped
,但没有任何反应。什么原因?我在这里做错了什么?有人可以帮我编辑我的代码,使其工作?滑动手势添加到UILabel,但它不起作用
请问您可以告诉我,将其添加到该标签的超级视图中是什么意思?我是否将它添加到'View'它自己而不是标签? – Illep
是的,我相信你正在给'view'加上'uilabel'的手势。所以,是的,你似乎添加到视图&不是标签的手势... –
感谢好友... – harshitgupta