ios - Multiple storyboards in Swift -
i have app has 4 storyboards, each different device (iphone4, 5, 6, 6+). have tried use auto constraints since app complicated, wasn't able figure out. have heard if have multiple storyboards there should way of specifying storyboard use in app delegate. how go specifying proper storyboard proper device in app delegate? have 4 storyboards, named:
iphone4s.storyboard
iphone5.storyboard
iphone6.storyboard
iphone6plus.storyboard
thank you.
implement function retrieves storyboard when it's name specified.
func getstoryboard(name : string)-> uistoryboard { var storyboard = uistoryboard(name: name, bundle: nil); return storyboard; }
change app delegate method like:
func application(application: uiapplication, didfinishlaunchingwithoptions launchoptions: [nsobject: anyobject]?) -> bool { var storyboard = getstoryboard("main") // change storyboard name based on device, may need write condition here var initialviewcontroller: uiviewcontroller = storyboard.instantiateinitialviewcontroller() as! uiviewcontroller self.window?.rootviewcontroller = initialviewcontroller self.window?.makekeyandvisible() // override point customization after application launch. return true }
Comments
Post a Comment