TextView's bounds issue

两盒软妹~` 提交于 2019-12-25 02:26:45

问题


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:


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



来源:https://stackoverflow.com/questions/25494260/textviews-bounds-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!