Swift - UISwipeGestureRecognizer Within UIScrollView
<p>I believe I found a solution but it's in Obj-C and I'm completely new &amp; confused into interpreting this into Swift: <a href="https://stackoverflow.com/questions/14054403/horizontal-uiswipegesturerecognizer-in-subview-of-uiscrollview-uiscrollview-o">Horizontal UISwipeGestureRecognizer in subview of UIScrollView ? (UIScrollView only needs to recognize vertical scrolling)</a> </p>

<p>I have my Main.storyboard which adds two sub-views where I can scroll horizontally between them. Currently, up and down swipes are detected but not the left and right due to the UIScrollView. Any workaround this interference? </p>

<p><strong>Main.storyboard:</strong></p>

<pre><code>// Global
let vc0 = ViewController0(nibName: "ViewController0", bundle: nil)
let vc1 = ViewController1(nibName: "ViewController1", bundle: nil)

class ViewController: UIViewController, UIScrollViewDelegate, UIGestureRecognizerDelegate {

@IBOutlet weak var scrollView: UIScrollView!

override func viewDidLoad() {
    super.viewDidLoad()

    self.addChildViewController(vc0)
    self.scrollView.addSubview(vc0.view)
    vc0.didMoveToParentViewController(self)

    var frame1 = vc1.view.frame
    frame1.origin.x = self.view.frame.size.width
    vc1.view.frame = frame1

    self.addChildViewController(vc1)
    self.scrollView.addSubview(vc1.view)
    vc1.didMoveToParentViewController(self)

    self.scrollView.contentSize = CGSizeMake(self.view.frame.size.width * 2, self.view.frame.size.height - 66)
    self.scrollView.delegate = self

    // Swipe Gesture Recognizers
    let swipeRight = UISwipeGestureRecognizer(target: self, action: #selector(ViewController.respondToSwipeGesture(_:)))
    swipeRight.direction = UISwipeGestureRecognizerDirection.Right
    let swipeLeft = UISwipeGestureRecognizer(target: self, action: #selector(ViewController.respondToSwipeGesture(_:)))
    swipeLeft.direction = UISwipeGestureRecognizerDirection.Left
    let swipeUp = UISwipeGestureRecognizer(target: self, action: #selector(ViewController.respondToSwipeGesture(_:)))
    swipeUp.direction = UISwipeGestureRecognizerDirection.Up
    let swipeDown = UISwipeGestureRecognizer(target: self, action: #selector(ViewController.respondToSwipeGesture(_:)))
    swipeDown.direction = UISwipeGestureRecognizerDirection.Down

    swipeRight.delegate = self
    swipeLeft.delegate = self

    self.view.addGestureRecognizer(swipeRight)
    self.view.addGestureRecognizer(swipeLeft)
    self.view.addGestureRecognizer(swipeUp)
    self.view.addGestureRecognizer(swipeDown)
}

func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWithGestureRecognizer otherGestureRecognizer: UIGestureRecognizer) -&gt; Bool {
    return true
}

func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldReceiveTouch touch: UITouch) -&gt; Bool {
    return true
}

// Debugging - Only Up &amp; Down Swipes Are Detected
func respondToSwipeGesture(gesture: UIGestureRecognizer) {
    if let swipeGesture = gesture as? UISwipeGestureRecognizer {
        switch swipeGesture.direction {
        case UISwipeGestureRecognizerDirection.Right:
            print("Swiped right")
        case UISwipeGestureRecognizerDirection.Down:
            print("Swiped down")
        case UISwipeGestureRecognizerDirection.Left:
            print("Swiped left")
        case UISwipeGestureRecognizerDirection.Up:
            print("Swiped up")
        default:
            break
        }
    }
}
}
</code></pre>