TextView的边界问题 [英] TextView's bounds issue
问题描述
我有一个带有平移手势识别器的视图,该视图调用了此方法
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];
}
如您所见,我也有一个textView,我想使用手势识别器滚动textView,它可以工作,但是当我执行新的拖动手势时会出现问题.总是(0,0)
.因此,在新拖动开始之前,textView仍会保持其边界.为什么?
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?
有人知道为什么每次调用此方法textView的 bounds.origin
都会返回到 CGPointZero
吗?预先感谢.
Does anybody know why textView's bounds.origin
returns to CGPointZero
every time this method is invoked? Thanks in advance.
推荐答案
This solves the problem.You need set translation to CGPointZero
every time you handle gesture.Otherwise it is concatenated.
这篇关于TextView的边界问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!