简体   繁体   中英

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; ). Then, reset it by executing fingerWasLifted = NO; in the

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

method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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