我想提供UIButton
不同的功能,具体取决于它是按下并释放一次,还是按住(理想情况下为 1.5 秒)并在屏幕上移动。我目前正在使用此代码:
[button addTarget:self action:@selector(open:)
forControlEvents:UIControlEventTouchDown]
panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(move:)];
[panRecognizer setMinimumNumberOfTouches:1];
[panRecognizer setMaximumNumberOfTouches:1];
[panRecognizer setDelegate:self];
[button addGestureRecognizer:panRecognizer];
-(IBAction)open:(id)sender {}
-(void)move:(id)sender{}
move:
工作正常,但open:
没有。