【问题标题】:Swipe Gesture StoryBoard Object in XCode 6 doesn't workXCode 6 中的滑动手势 StoryBoard 对象不起作用
【发布时间】:2015-06-10 21:24:55
【问题描述】:

我尝试使用 StoryBoard 中的滑动手势识别器对象在视图控制器之间滑动,但不起作用。

  • App 由一个 Tab Bar Controller 和 4 个视图控制器组成,每个视图控制器都有一个视图、表格视图、表格视图单元格和图像视图。
  • 首先我将对象拖到每个视图控制器,之后我使用 ctrl + 将对象拖到目标视图控制器以创建“Push segue to View Controller”,选择 Action segue = push,我给它一个标识符,我取消选中取消触摸视图,最后我检查了用户交互启用。

我该如何做才能让应用滑动?

【问题讨论】:

    标签: ios xcode swift


    【解决方案1】:

    您可以通过向视图控制器添加手势识别器以编程方式完成此操作。在视图控制器的 - (void)viewDidLoad 方法中,您可以添加以下内容:

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

    然后在您的视图控制器中创建- (void)swipedRight。如果您想调用您在故事板中创建的 segue,则只需将 [self performSegueWithIdentifier:@"segueID" sender:self]; 放入您的 swipedRight 函数中即可。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-02-08
      • 2015-10-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多