我们如何限制iPhone中的手势?

发布于 2024-12-17 18:51:57 字数 1532 浏览 1 评论 0原文

我的视图中有三种类型的手势(tableview 是我的视图) PinchGesture:重定向到另一个页面 向左滑动:进入下一章 RightSwipe:查看上一章 滚动:tableview滚动 我的要求是,当任何一个手势执行其他手势(包括桌面视图的滚动)时,都必须禁用,这可能吗? 我的手势代码是

-(void) handleSwipeGesture:(UISwipeGestureRecognizer*)recognizer {


     if(![delegate.selectedChapter isEqualToString:[NSString stringWithFormat:@"%d",[DbHandler mNumberOfChaptersInBook:delegate.selectedBook]]]) {
        // if the currentChapter is the last then do nothing
         delegate.selectedChapter = [NSString stringWithFormat:@"%d",[delegate.selectedChapter intValue] + 1];
         [delegate reloadVerses];
         [self resetReadViewToVerse:1];
    }
    return;




}
-(void) handleSwipeGestureleft:(UISwipeGestureRecognizer*)recognizer {

    if(![delegate.selectedChapter isEqualToString:@"1"])
    {
        delegate.selectedChapter = [NSString stringWithFormat:@"%d",[delegate.selectedChapter intValue] - 1];
        [delegate reloadVerses];
        [self resetReadViewToVerse:1]; 
    }
    return;


}
-(void) longPressDetected:(UISwipeGestureRecognizer*)recognizer {


    SearchViewController *aSecondViewController = [[SearchViewController alloc] initWithNibName:@"SearchViewController" bundle:nil];
    aSecondViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentModalViewController:aSecondViewController animated:YES];

    /*[self.navigationController pushViewController:aSecondViewController animated:YES];*/

    [aSecondViewController release];
    [UIView commitAnimations];

}

I have Three type of gestures in my view(tableview is my view)
PinchGesture:redirecting to another page
LeftSwipe:for next chapter
RightSwipe:for previos chapter
Scrolling:tableview scrolling
My requirement is when any one of the gesture acts the other gestures including scrolling of tableview have to be disabled,Is this possible?
my code for gesture is

-(void) handleSwipeGesture:(UISwipeGestureRecognizer*)recognizer {


     if(![delegate.selectedChapter isEqualToString:[NSString stringWithFormat:@"%d",[DbHandler mNumberOfChaptersInBook:delegate.selectedBook]]]) {
        // if the currentChapter is the last then do nothing
         delegate.selectedChapter = [NSString stringWithFormat:@"%d",[delegate.selectedChapter intValue] + 1];
         [delegate reloadVerses];
         [self resetReadViewToVerse:1];
    }
    return;




}
-(void) handleSwipeGestureleft:(UISwipeGestureRecognizer*)recognizer {

    if(![delegate.selectedChapter isEqualToString:@"1"])
    {
        delegate.selectedChapter = [NSString stringWithFormat:@"%d",[delegate.selectedChapter intValue] - 1];
        [delegate reloadVerses];
        [self resetReadViewToVerse:1]; 
    }
    return;


}
-(void) longPressDetected:(UISwipeGestureRecognizer*)recognizer {


    SearchViewController *aSecondViewController = [[SearchViewController alloc] initWithNibName:@"SearchViewController" bundle:nil];
    aSecondViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentModalViewController:aSecondViewController animated:YES];

    /*[self.navigationController pushViewController:aSecondViewController animated:YES];*/

    [aSecondViewController release];
    [UIView commitAnimations];

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只是一片海 2024-12-24 18:51:57

当您的手势识别器方法被调用时,您可以尝试。

if (recognizer.state==UIGestureRecognizerStateEnded) {
    //Do your thing.
}

HTH。

When your gesture recognizer method is called you can try.

if (recognizer.state==UIGestureRecognizerStateEnded) {
    //Do your thing.
}

HTH.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文