所以我有一个UITextView,我用它来允许用户提交一些文本.
我的问题是,我似乎无法弄清楚如何通过点击UITextView来允许用户"取消".
我有一个 UIScrollView,它的高度约为 600 像素,宽度约为 320。所以我允许用户垂直滚动。
我也在尝试捕获视图上的水平滑动。问题似乎是,当用户在水平方向滑动时意外垂直移动时,UIScrollView 滚动并且我的 touchesEnded 委托方法永远不会被调用。
这是我的代码:
- (void)touchesEnded: (NSSet *)touches withEvent: (UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint currentPosition = [touch locationInView:self];
if (currentPosition.x + 35 < gestureStartPoint.x)
{
NSLog(@"Right");
}
else if (currentPosition.x - 35 > gestureStartPoint.x)
{
NSLog(@"Left");
}
else if (!self.dragging)
{
[self.nextResponder touchesEnded: touches withEvent:event];
}
[super touchesEnded: touches withEvent: event];
}
Run Code Online (Sandbox Code Playgroud)
有谁知道即使涉及垂直阻力,我如何才能使其工作?