Ios 检测从手势识别器对象外部开始的刷卡';s区

Ios 检测从手势识别器对象外部开始的刷卡';s区,ios,xcode,uigesturerecognizer,uiswipegesturerecognizer,Ios,Xcode,Uigesturerecognizer,Uiswipegesturerecognizer,我正试图以一种非常具体的方式检测刷卡,结果好坏参半。我的第一个问题是只在屏幕的某个区域识别刷卡,现在这个问题已经解决了。我目前的问题是:假设我的视图中有一个thing列,我将该列的维度与我的手势识别器相对应。使用该应用程序时,刷卡必须在这些维度内开始,才能识别为刷卡。相反,即使用户开始在列的区域外刷卡,我也需要识别刷卡。事实上,我甚至不在乎它是否是一次刷卡,甚至是一次轻触或其他什么都可以,我只想知道用户的手指是否曾经在该列中(在这种情况下,他们肯定会从该列的区域外开始刷卡) 以下是我的当前代码,

我正试图以一种非常具体的方式检测刷卡,结果好坏参半。我的第一个问题是只在屏幕的某个区域识别刷卡,现在这个问题已经解决了。我目前的问题是:假设我的视图中有一个thing列,我将该列的维度与我的手势识别器相对应。使用该应用程序时,刷卡必须在这些维度内开始,才能识别为刷卡。相反,即使用户开始在列的区域外刷卡,我也需要识别刷卡。事实上,我甚至不在乎它是否是一次刷卡,甚至是一次轻触或其他什么都可以,我只想知道用户的手指是否曾经在该列中(在这种情况下,他们肯定会从该列的区域外开始刷卡)

以下是我的当前代码,其中包含单词,但刷卡必须从列内开始:

- (IBAction)swiperMethod:(UISwipeGestureRecognizer *)sender {
    CGPoint point = [sender locationInView:self.view];
    if(point.y < 316 && point.y > 76 && point.x < 234 && point.x > 164)
    {
        _sampleText.text=@"hi";
    }
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    UISwipeGestureRecognizer *leftRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swiperMethod:)];
    [leftRecognizer setDirection: UISwipeGestureRecognizerDirectionLeft];
    [[self view] addGestureRecognizer:leftRecognizer];
    // Do any additional setup after loading the view, typically from a nib.
}
-(iAction)SwipMethod:(UISwipegestureRecognitor*)发送方{
CGPoint point=[sender locationInView:self.view];
如果(点y<316和点y>76和点x<234和点x>164)
{
_text=@“嗨”;
}
}
-(无效)viewDidLoad
{
[超级视图下载];
UISweepGestureRecognizer*leftRecognizer=[[UISweepGestureRecognizer alloc]initWithTarget:self action:@selector(SwipMethod:)];
[左侧识别器设置方向:UISweepGestureRecognitizerDirectionLeft];
[[self-view]AddGestureRecognitor:LeftRecognitor];
//加载视图后,通常从nib执行任何其他设置。
}
有人能告诉我,即使用户只是将手指拖过这一区域,如何识别刷卡(或任何手势,我不关心它是否是刷卡)

谢谢

这个方法有效

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch * touch = [[event allTouches] anyObject];
    CGPoint point = [touch locationInView:touch.view];
    if(point.y < 316 && point.y > 76 && point.x < 234 && point.x > 164)
    {
        _sample.image = [UIImage imageNamed:@"normal.png"];
    }
    else
    {
        _star.image = [UIImage imageNamed:@"alternate.png"];
    }

}
-(无效)触摸移动:(NSSet*)触摸事件:(UIEvent*)事件
{
UITouch*touch=[[event AllTouchs]anyObject];
CGPoint point=[touch locationInView:touch.view];
如果(点y<316和点y>76和点x<234和点x>164)
{
_sample.image=[UIImage ImageName:@“normal.png”];
}
其他的
{
_star.image=[UIImage ImageName:@“alternate.png”];
}
}
此方法有效

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch * touch = [[event allTouches] anyObject];
    CGPoint point = [touch locationInView:touch.view];
    if(point.y < 316 && point.y > 76 && point.x < 234 && point.x > 164)
    {
        _sample.image = [UIImage imageNamed:@"normal.png"];
    }
    else
    {
        _star.image = [UIImage imageNamed:@"alternate.png"];
    }

}
-(无效)触摸移动:(NSSet*)触摸事件:(UIEvent*)事件
{
UITouch*touch=[[event AllTouchs]anyObject];
CGPoint point=[touch locationInView:touch.view];
如果(点y<316和点y>76和点x<234和点x>164)
{
_sample.image=[UIImage ImageName:@“normal.png”];
}
其他的
{
_star.image=[UIImage ImageName:@“alternate.png”];
}
}

没有人有任何想法?还是我的问题不准确?没有人有任何想法?还是我的问题不准确?嘿,杰克,9115!快速提问,如果用户触摸也从屏幕外开始,这是否有效?我有一个隐藏的菜单,我想从右边拉进去,通常触摸会从屏幕外开始…嘿,杰克9115!快速提问,如果用户触摸也从屏幕外开始,这是否有效?我有一个隐藏的菜单,我想从右边拉进去,通常触摸会从屏幕外开始。。。