I try to get touch position when I scroll the screen. I try to get it from touchBegin() but I can't. That开发者_运维问答's because touchBegin never called during scroll. How can I solve this problem??? Quickly Answer to me.
using the scrollview gesture recognizer :
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGPoint positionInView = [scrollView.panGestureRecognizer locationInView:myView];
}
I found my self it solution.
First, I set the scrollView.contentSize to scrollView.frame. so it can't call scrollViewDidScroll
- (id)initWithFrame:(CGRect)frame
{
....
self.frame = frame
self.contentSize = frame;
....
}
Second, when touchesBegan set the scrollView.contentSize what I want. then the event will go to scrollViewDidScroll. You can act something.
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
....
self.contentSize = myView.frame.size;
....
}
Thrid, in scrollViewDidEndDecelerating set the contentSize and save the contentOffest;
-(void) scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
CGPoint pointTemp = self.contentOffset;
self.contentSize = self.frame.size;
self.contentOffset = pointTemp;
}
This will be pathetic way. If you know other, please teach me
精彩评论