Implementing UISwipeGestureRecognizer into app

Discussion in 'iOS Programming' started by Dj64Mk7, Oct 7, 2016.

  1. Dj64Mk7 macrumors 65816

    Sep 15, 2013
    I'm building a simple app that allows the user to swipe through a selection of photos. I have an image in the initial view controller, and I added a second view controller with image. I added a Swipe Gesture Recognizer to both views, but I don't know how to implement and connect them.

    Any help will be greatly appreciated.

    Many thanks.
  2. AxoNeuron macrumors 65816


    Apr 22, 2012
    The Left Coast
    First you shouldn't use a UISwipeGestureRecognizer. It would feel really unnatural. A better alternative would be to use UIPanGestureRecognizer.

    You would then check for a certain velocity and when reached, swipe to the next image.

    But really, this is a solved problem and has been for years. My personal favorite library in this situation is called SwipeView (that's the cocoapod). But these days you can also use a simple UICollectionView with paging enabled.
  3. Dj64Mk7 thread starter macrumors 65816

    Sep 15, 2013
    Can you go into a bit more detail on UIPanGestureRecognizer?

    I'm sorry for it not being clear to me. I'm very new to iOS Development. I have two View Controllers in Main.storyboard, both with UIImageView's. How do I connect the initial View Controller to the second?
  4. bjet767 macrumors 6502a

    Oct 2, 2010
    What you are asking is fundamental to iOS programming and there are a number of ways to make this happen with the easiest being a segue.

    What you really need to do is go through the tutorials mention here and on many similar threads and look for the transition you want to achieve.

    If you simply want to run a slide show of images there are tutorials out on the web which will walk you through what you need to know.

    Additionally this site,, is full of answers for what you may be desiring. It is the goto place for code questions and answers.

Share This Page