Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a view with pan gesture recognizer,which invokes this method

- (IBAction)handlePanGesture:(UIPanGestureRecognizer *)gestureRecognizer
{
translation = [gestureRecognizer translationInView:self.trackingView];
bounds = self.myTextView.bounds;
newBoundsOriginY = (bounds.origin.y - translation.y)/3.52;
self.myTextView.contentOffset = CGPointMake(0,newBoundsOriginY);
//[self.myTextView scrollRectToVisible:bounds animated:NO];
}

As you can see I also have a textView and I want to scroll the textView using gesture recognizer.It works, but the problem occurs when I perform new dragging gesture.When I do this I get textView's bounds.origin always (0,0).So textView remains it's bounds until the new drag begins.Why?

Does anybody know why textView's bounds.origin returns to CGPointZero every time this method is invoked? Thanks in advance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
188 views
Welcome To Ask or Share your Answers For Others

1 Answer

This solves the problem.You need set translation to CGPointZero every time you handle gesture.Otherwise it is concatenated.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...