I have decided to avoid using auto-layout so I am instead currently trying to implement the code to make my app manage two different storyboards based on screen size.
I have been following this tutorial: http://pinkstone.co.uk/how-to-load-a-different-storyboard-depending-on-screen-size-in-ios/
I am having issues trying to translate the Objective C code into Swift.
Here is the code that I currently have in my AppDelegate:
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func grabStoryboard() -> UIStoryboard {
var storyboard = UIStoryboard()
var height = UIScreen.mainScreen().bounds.size.height
if height == 480 {
storyboard = UIStoryboard(name: "Main3.5", bundle: nil)
} else {
storyboard = UIStoryboard(name: "Main", bundle: nil)
}
return storyboard
}
func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: NSDictionary!) -> Bool {
// Override point for customization after application launch.
var storyboard: UIStoryboard = self.grabStoryboard()
self.window?.rootViewController.storyboard.instantiateInitialViewController()
self.window?.makeKeyAndVisible()
return true
}
The app runs, and I have no errors however no matter whether I run the app on a 3.5 inch device or a 4 inch device, I just get the 4 inch storyboard.
Where am I going wrong?