Hi I checked many questions regarding swiping in SO but have doubts .
In my app I have two pages 1. user view controller 2. question view controller
user page l
First you'll have to add a UIPanGestureRecognizer
to your "questions bar" so you can pan it to show the questions view.
To handle multiple view controllers, you can use a container view controller:
var pendingViewController: UIViewController? {
didSet {
if let pending = pendingViewController {
addChildViewController(pending)
pending.didMoveToParentViewController(self)
pending.view.frame.origin.y = UIScreen.mainScreen().bounds.height
view.addSubview(pending.view)
}
}
}
var currentViewController: UIViewController? { didSet { pendingViewController = nil } }
func showQuestions(recognizer: UIPanGestureRecognizer) {
if recognizer.state == .Began {
let controller = QuestionViewController() // create instance of your question view controller
pendingViewController = controller
}
if recognizer.state == .Changed {
let translation = recognizer.translationInView(view)
// Insert code here to move whatever you want to move together with the question view controller view
pendingViewController.view.center.y += translation.y
recognizer.setTranslation(CGPointZero, inView: view)
}
if recognizer.state == .Ended {
// Animate the view to it's location
}
}
Something like this. This is all typed manually so there might be some mistakes.