Lomotif / swipe-navigation

Snapchat like 4-way swipe navigation in Swift for iOS
MIT License
43 stars 11 forks source link

Swipe not working #3

Closed christopheretcheverry closed 7 years ago

christopheretcheverry commented 8 years ago

I cannot get swipe to work at all in swift 3. When I add a directional controller all it does is make my background blue.

let storyboard = UIStoryboard(name: "Main", bundle: nil) let rightController = storyboard.instantiateViewController(withIdentifier: "right") let swipeNavigationController = SwipeNavigationController(centerViewController: self) swipeNavigationController.rightViewController = rightController

I'm not a very experienced iOS developer so a more complete example would be helpful.

Thanks!

tsukisa commented 7 years ago

Hi @christopheretcheverry,

I am sorry that currently it does not work really well with storyboard yet.

Here's the sample code you can use with your view controllers created by storyboard. In your AppDelegate, you can override the default view controller by adding this code at func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool:

// Instantiate main storyboard
let storyboard = UIStoryboard(name: "Main", bundle: nil)

// Instantiate main view controller
let mainViewController = storyboard.instantiateInitialViewController()!

// Instantiate swipe navigation controller with mainViewController as center view controller
let swipeNavigationController = SwipeNavigationController(centerViewController: mainViewController)

// Set right view controller
swipeNavigationController.rightViewController = storyboard.instantiateViewController(withIdentifier: "right")

// Set default view 
self.window = UIWindow(frame: UIScreen.main.bounds)
self.window?.rootViewController = swipeNavigationController
self.window?.makeKeyAndVisible()

Hope this helps!

christopheretcheverry commented 7 years ago

Hey this helps, thanks for the feedback. I'm still mysteriously getting a blue background when I add this code.

tsukisa commented 7 years ago

I accidentally left the code that will set center view background color to blue which was meant for testing purpose. It was already removed in version 2.0.1.