【发布时间】:2014-10-19 02:18:54
【问题描述】:
我有一个带有平移手势识别器的视图,它调用了这个方法
- (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。它可以工作,但是当我执行新的拖动手势时会出现问题。当我这样做时,我得到 textView 的 bounds.origin 总是 @987654323 @.So textView 在新的拖动开始之前保持它的边界。为什么?
有谁知道为什么每次调用这个方法时textView的bounds.origin返回CGPointZero?提前致谢。
【问题讨论】:
-
也许这与框架与边界有关。
bounds是指视图本身,而frame是指父视图,所以也许您想考虑相对于其父视图移动视图:即使用frame而不是(或与)bounds. -
@KonsolLabapen 不。我需要准确地滚动文本视图,我不想改变它在超级视图坐标系中的位置。
标签: ios iphone uitextview frame bounds