iOS7中的滑动手势控制问题

时间:2014-03-27 11:10:56

标签: ios iphone ios7 gesture

在我的应用程序中,我使用的是Swipe Gesture Control。我有一个表视图和一个视图控制器。 我的视图设计如下: - enter image description here enter image description here 当滑动它会很好。但问题是,当快速滑动时,它会显示为重叠的条形按钮 enter image description here 解决方案是什么。我刚试过这段代码

 if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
    self.navigationController.interactivePopGestureRecognizer.enabled = YES;

}

我也在表格视图中使用了隐藏按钮的代码  它不适用于我的project.pls帮助我

2 个答案:

答案 0 :(得分:3)

在viewDidLoad中的视图控制器中发布此代码..

UISwipeGestureRecognizer *swipeLeft =[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeLeft:)];
swipeLeft.direction =UISwipeGestureRecognizerDirectionRight;
[self.view addGestureRecognizer:swipeLeft];

UISwipeGestureRecognizer *swipeRight =[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeRight:)];
swipeRight.direction =UISwipeGestureRecognizerDirectionLeft;
[self.view addGestureRecognizer:swipeRight];

为swipeLeft:和swipeRight:

添加方法

希望这会对你有帮助..

swipeLeft代码:和swipeRight:

-(IBAction)swipeLeft:(id)sender
{
            CView *view =[[CView alloc]initWithNibName:@"CView" bundle:Nil];
            CATransition *animation = [CATransition animation];
            [self.navigationController pushViewController:view animated:NO];
            [animation setDuration:0.30];
            [animation setType:kCATransitionPush];
            [animation setSubtype:kCATransitionFromLeft];
            [[view.view layer] addAnimation:animation forKey:@"CView"];
}
-(IBAction)swipeRight:(id)sender
{
        EView *view =[[EView alloc]initWithNibName:@"EView" bundle:Nil];
        view.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
        [self.navigationController pushViewController:view animated:YES];;
        [view release];
}

希望这会对你有帮助..

答案 1 :(得分:0)

使用以下方法。它会在您滑动时调用

希望这会对你有所帮助。

- (void)swipeLeft:(UITapGestureRecognizer *)recognizer{
    // Insert your own code to handle swipe left
}
- (void)swipeRight:(UITapGestureRecognizer *)recognizer {
    // Insert your own code to handle swipe right
}
相关问题