TextView's bounds issue

2019-09-06 00:33发布

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.

1条回答
聊天终结者
2楼-- · 2019-09-06 00:42

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

查看更多
登录 后发表回答