TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Oct 2016 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by Matteo Crippa.
To run the example project, clone the repo, and run pod install
from the Example directory first.
First of all make sure that inside your AppDelegate
func didFinishLaunchingWithOptions
we have this snippet:
window = UIWindow(frame:UIScreen.mainScreen().bounds)
Then you have to create a new enum of type StoryboardEnum
.
import StoryboardEnum
enum Storyboard: StoryboardEnum {
case Main
var story: StoryboardVC {
return StoryboardVC(inWindow: UIApplication.sharedApplication().windows.first!)
}
var vc: UIViewController? {
switch self {
case Main:
return story.getVC(fromStoryboard: "Main", withIdentifier: "Main")
}
}
}
Finally you have only to call wherever you want to present the view controller:
Storyboard.Name.show()
you can even show the vc embedded in a navigation using:
Storyboard.Name.show(inNavigation: true)
IMPORTANT If you plan to omit the identifier
of the VC, please check that there is at least one VC set to be Initial view controller
in your storyboard to avoid the app to crash.
I’ve added a nice way to embed a VC in navigationController, using embedInNavigation()
func you will received your navigation w/ the view inside.
StoryboardEnum is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "StoryboardEnum"
Matteo Crippa, @ghego20
StoryboardEnum is available under the MIT license. See the LICENSE file for more info.