将UIPageViewController与UIPanGestureRecognizer一起使用

时间:2015-07-08 17:39:01

标签: swift uigesturerecognizer

我的应用程序是使用UIPageViewController的基于页面的应用程序。现在我想能够在我的页面上垂直移动子视图。实现UIPanGestureRecognizer后,我能够移动子视图,但现在我的水平滑动在页面中移动不起作用...

我如何结合这两个手势? 这是我的panGestureRecognizer:

ContentViewController.swift

var panSwipe = UIPanGestureRecognizer(target: self, action: Selector("handlePanSwipe:"))

view.addGestureRecognizer(panSwipe)

...

func handlePanSwipe(sender:UIPanGestureRecognizer) {

    var translation = sender.translationInView(self.view)

    if sender.state == UIGestureRecognizerState.Began {
        startLocation = sender.locationInView(self.view)
    } else if (sender.state == UIGestureRecognizerState.Changed) {
        self.settingsView.frame.origin.y = self.newSettingsFrameOrigin!.y + translation.y
    } else if (sender.state == UIGestureRecognizerState.Ended) {
        self.newSettingsFrameOrigin = self.settingsView.frame.origin
}

我希望能够上下移动深绿色子视图:

enter image description here

提前致谢!

0 个答案:

没有答案