0

我有一个问题,UISwipeGestureRecognizer找不到解决方案。

我只想UISwipeGestureRecognizer在视图的一半上使用。但我也想在我的视图上使用按钮。

这就是我所做的。

我有一个768 x 1024 像素的UIView名称firstView,上面有按钮。

现在我想在名为768 x 512 像素的名称上添加一个UIView或。UIImageViewfirstViewsecondView

滑动会起作用,但我下面的按钮secondView(按钮打开firstView)不起作用。

我错过了什么功能让两个视图都响应?
还是有比我上面描述的更好的方法?

我的刷卡码:

UIImageView *secondView = [[[UIImageView alloc] initWithFrame:
                              CGRectMake(0,0,768,512)] autorelease];
//UIView *secondView = [[[UIView alloc] initWithFrame:CGRectMake(0,0,768,512)] autorelease];

secondView.userInteractionEnabled = YES;    

[firstView addSubview:secondView];

oneFingerSwipeLeft = [[[UISwipeGestureRecognizer alloc] initWithTarget:self 
                         action:@selector(swipeRecognition:)] autorelease];
[oneFingerSwipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft];
[secondView addGestureRecognizer:oneFingerSwipeLeft];
4

1 回答 1

0

我为自己找到了解决方案。我将屏幕分为 4 个视图。现在我可以为每个视图提供自己的手势识别。

    // set CGRect for downLeftView
    downLeftView = [[[UIImageView alloc] initWithFrame:CGRectMake(0,512,384,512)] autorelease];

    // set CGRect for downRightView
    downRightView = [[[UIImageView alloc] initWithFrame:CGRectMake(384,512,384,512)] autorelease];

    // set CGRect for upRightView
    upRightView = [[[UIImageView alloc] initWithFrame:CGRectMake(0,0,384,512)] autorelease];

    // set CGRect for upLeftView
    upLeftView = [[[UIImageView alloc] initWithFrame:CGRectMake(384,0,384,512)] autorelease];
于 2012-04-02T10:40:54.790 回答