Lomotif / swipe-navigation

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

Swift 4? #16

Open jonathansolorzn opened 7 years ago

jonathansolorzn commented 7 years ago

I tried to use it in Xcode 9 and Swift 4 app, didn't opened my app, could you give an example of how to use it?

doudouperrin commented 6 years ago

Using the simple ReadMe sample codes works perfectly for me. I do not use cocoapod though, but it should not change anything.

If your app crashes just after the launch, I suspect you miss a link between your controllers and the storyboard.

1) Instanciate your controllers from you appDelegate or from a Loading controller for example (I suppose you have a storyboard) :

`let storyboard = UIStoryboard(name: "Main", bundle: nil)

let swipeNavigationController = SwipeNavigationController(centerViewController: storyboard.instantiateViewController(withIdentifier: "RecordNavVC"))

swipeNavigationController.topViewController = storyboard.instantiateViewController(withIdentifier: "topVC") swipeNavigationController.bottomViewController = storyboard.instantiateViewController(withIdentifier: "bottomVC") swipeNavigationController.leftViewController = storyboard.instantiateViewController(withIdentifier: "leftVC") swipeNavigationController.rightViewController = storyboard.instantiateViewController(withIdentifier: "rightVC")

// Lock botom and right swipe (for example) swipeNavigationController.shouldShowBottomViewController = false swipeNavigationController.shouldShowRightViewController = false

let appDelegate = UIApplication.shared.delegate as! AppDelegate appDelegate.window?.rootViewController = swipeNavigationController appDelegate.window?.makeKeyAndVisible()`

2) /!\ Do not forget to create your View controllers in storyboard and to set the Storyboard for each (which correspond to your initialization code).

3) You can access the SwipeViewController instance inside your controllers : override func viewDidLoad() { if let swipeNavCtrl = containerSwipeNavigationController { swipeNavController = swipeNavCtrl } }

Hope it helps. Swift 4 / Xcode 9.2.

sashahilton00 commented 6 years ago

@ep372 is there any chance you could upload a sample project just demonstrating using this library with a storyboard views? I'm having trouble working this out, and am also having trouble with the fact that all four views in the project are controlled by the EmbeddedViewController class. I would be most appreciative :)

doudouperrin commented 6 years ago

@sashahilton00 Ok I will, maybe before the end of the week. Otherwise next week ;)

sashahilton00 commented 6 years ago

@ep372 thanks, much appreciated :)

UNLK8852 commented 6 years ago

Do you know where I could find that?