小编tuz*_*ron的帖子

在UITextView上失去焦点时隐藏键盘

所以我有一个UITextView,我用它来允许用户提交一些文本.

我的问题是,我似乎无法弄清楚如何通过点击UITextView来允许用户"取消".

iphone cocoa-touch objective-c uitextview uikit

45
推荐指数
3
解决办法
4万
查看次数

使用垂直滚动检测 UIScrollView 中的水平滑动

我有一个 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)

有谁知道即使涉及垂直阻力,我如何才能使其工作?

uiscrollview uikit ios

5
推荐指数
1
解决办法
1万
查看次数