-3

I have a problem and I have no idea for that...

I want change interface like setting:settings.gif

I do not know even the key word to search it in the internet...

I used "interactive transition" and "gesture interactive" etc... but I can not find a right answer or demo or code...

Could you tell me how to code to change interface like settings of system iOS (a tutorial perhaps...)? Thank you very much !

PS : I created the two views by uiviewcontroller, not uinavigationController

user2262304
  • 329
  • 1
  • 3
  • 10

2 Answers2

0

It is called interactivePopGestureRecognizer

self.navigationController?.interactivePopGestureRecognizer?.delegate = self self.navigationController?.interactivePopGestureRecognizer?.enabled = true

put that lines in your ViewController class and add UIGestureRecognizerDelegate to your class

class ViewControllerClass : UIViewController, UIGestureRecognizerDelegate {
// class methods
}

You can also implement delegate methods

func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWithGestureRecognizer otherGestureRecognizer: UIGestureRecognizer) -> Bool {
    return true
}

func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldBeRequiredToFailByGestureRecognizer otherGestureRecognizer: UIGestureRecognizer) -> Bool {
    return (gestureRecognizer is UIScreenEdgePanGestureRecognizer)
}
kamwysoc
  • 6,709
  • 2
  • 34
  • 48
  • Thank you for you answer, I have two view : `class ViewController: UIViewController, UITextFieldDelegate, UITextViewDelegate` and `class LoginViewController: UIViewController, UITextFieldDelegate,UIGestureRecognizerDelegate`, there is a button in the `class ViewController` to show `class LoginViewController`, I did like you said : I added your code in the class `class LoginViewController`, but it does not works... – user2262304 Apr 15 '16 at 10:58
  • First, check if your navigationController is not nil and try to add this line `self.navigationController?.interactivePopGestureRecognizer?.enabled = true ` default is true, but add it to make sure it's all OK. Also it would be nice if you provide your code with these two controllers – kamwysoc Apr 15 '16 at 11:05
  • Thank you for your answer, I do not how to check navigationController is null or not...but I think it is null, because the two view are `UIViewController`, and I never define a navigationController in class by code...I just add a navigationController in the XIB...So what I should do ? Thank you. I tried your code, it does not work...I think because navigationController is null, how to give a value to navigationController in the class `UIViewController` ? Thank you – user2262304 Apr 15 '16 at 11:22
  • I created the two view by uiviewcontroller, not uinavigationController lol – user2262304 Apr 15 '16 at 11:28
  • To achieve this effect you need UINavigationController with UIViewController – kamwysoc Apr 15 '16 at 11:32
  • I have used UINavigationController to show another view, but I want to I can do like settings of system iOS from second view to first view, not only by a button back, Could you give me some help ? I think it is not easy, because I have searched it on internet, but I can not find a right answer, on internet, they all use `UIPercentDrivenInteractiveTransition` not `UIViewController`... – user2262304 Apr 15 '16 at 11:41
0

I have fund my answer, I push it there, because I think this perhaps will help other beginners.

1) I embedded in a navigation bar for a view.

2) after 1), we can use

let secondViewController = self.storyboard!.instantiateViewControllerWithIdentifier("Your view") as! LoginViewController

        self.navigationController!.pushViewController(secondViewController, animated: true)

3) In the seconde view, there will have a backbitten automatic, and we can do like settings of system iOS

user2262304
  • 329
  • 1
  • 3
  • 10