Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iphone开发:在滚动视图上滑动识别器_Iphone_Objective C_Ios_Uiscrollview_Swipe - Fatal编程技术网

iphone开发:在滚动视图上滑动识别器

iphone开发:在滚动视图上滑动识别器,iphone,objective-c,ios,uiscrollview,swipe,Iphone,Objective C,Ios,Uiscrollview,Swipe,在我的应用程序中,我的背景滚动条上有一个向上方向滑动的手势识别器,但不知怎么的,它不起作用。下面是我的代码 它在viewDidLoad中 UISwipeGestureRecognizer *Swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(SwipeRecognizer:)]; Swipe.direction = UISwipeGestureRecognizerDirectionUp; [

在我的应用程序中,我的背景滚动条上有一个向上方向滑动的手势识别器,但不知怎么的,它不起作用。下面是我的代码

它在viewDidLoad中

UISwipeGestureRecognizer *Swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(SwipeRecognizer:)];
Swipe.direction = UISwipeGestureRecognizerDirectionUp;
[backgroundScroller addGestureRecognizer:Swipe];
它是瑞士认知者:

- (void) SwipeRecognizer:(UISwipeGestureRecognizer *)sender {
    if (sender.direction | UISwipeGestureRecognizerDirectionUp){
        NSLog(@" *** SWIPE UP ***");
    }
}
然而,我不能有任何日志。我错过什么了吗?谢谢


编辑:我发现了问题。当我说滚动未启用时,我可以识别该手势。但我需要同时进行滚动和手势识别。难道不可能吗?

在.h文件中注册UIgestureRecognitizerDelegate,如下所示:

@interface yourViewController : UIViewController<UIGestureRecognizerDelegate>

像这样试试。如果你没有得到任何
NSLog(@“***swipereconcegnizer***”)
输出,那么我认为你没有在swipereconcegnizer上下功夫

- (void) SwipeRecognizer:(UISwipeGestureRecognizer *)sender {
 NSLog(@" *** SwipeRecognizer ***");
if (sender.direction == UISwipeGestureRecognizerDirectionUp){
    NSLog(@" *** SWIPE UP ***");
}
}

我想这会对您有所帮助。

调试和检查方法被调用。我尝试过它。是的,这就是问题所在。不知何故,该方法没有调用,但我不知道为什么:/您的scrollview中包含什么?将ImageViewNo的userInteraction启用为“是”,但我仍然没有任何日志。
- (void) SwipeRecognizer:(UISwipeGestureRecognizer *)sender {
 NSLog(@" *** SwipeRecognizer ***");
if (sender.direction == UISwipeGestureRecognizerDirectionUp){
    NSLog(@" *** SWIPE UP ***");
}
}