简体   繁体   English

如何识别手指何时从屏幕上抬起?

[英]How to recognise when a finger was lifted from the screen?

I have a scroll view that I'm using its delegate method: 我有一个正在使用其委托方法的滚动视图:

(void)scrollViewDidScroll:(UIScrollView *)scrollView

And I want to perform some action after my content offset is at some point, and the finger was pulled from the screen....How do I find out if the finger was lifted? 我想在内容偏移量达到某个点并从屏幕上拉出手指后执行一些操作。...如何确定手指是否被抬起?

this is what I have so far: 这是我到目前为止所拥有的:

if (self.myScrollView.contentOffset.y <= -73 && HereINeedToFindOutIfTheFingerWasLifted)

Thanks!!! 谢谢!!!

You can try the method: 您可以尝试以下方法:

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate

This fires when the user stops manually dragging, but the scrollview may still be decelerating. 当用户停止手动拖动时会触发,但滚动视图可能仍在减速。

I suggest your delegate implement the 我建议您的代表实施

-(void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset

method and have it set some BOOL instance variable (ie, fingerWasLifted = YES; ). 方法,并设置一些BOOL实例变量(即fingerWasLifted = YES; )。 Then, reset it by executing fingerWasLifted = NO; 然后,通过执行fingerWasLifted = NO;重置它fingerWasLifted = NO; in the 在里面

-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView;

method. 方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM