【问题标题】:Issue with Swipe Gesture Control in iOS7iOS7 中的滑动手势控制问题
【发布时间】:2014-03-27 11:10:55
【问题描述】:

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

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

}

我还使用了表格视图中隐藏后退按钮的代码 它不适用于我的项目。请帮助我

【问题讨论】:

  • 您可以尝试以下操作:[mySwipeGesture requireGestureRecognizerToFail:self.navigationController.interactivePopGestureRecognizer] 在 if 情况下。
  • 它不起作用。再次显示相同的错误

标签: ios iphone ios7 gesture


【解决方案1】:

将此代码发布到 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: 的 put 方法

希望对你有所帮助..

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];
}

希望对你有所帮助..

【讨论】:

  • 滑动时不调用此方法
  • 它会更快地查看控制器我刚刚尝试了以下代码 -(void)swipeLeft:(id)sender{ [self.navigationController popViewControllerAnimated:YES]; }
  • 请指定CView和EView
  • 这是您必须提供的 xib 名称.. 或者您可以将其应用于当前视图.. 这只是您必须放置自己的代码的示例@PraphinSP
  • @PraphinSP in ios7 这是默认布局,不需要设置任何东西..只需从 AppDelegate 将导航控制器添加到根视图控制器..
【解决方案2】:

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

希望这会对您有所帮助。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多