前準備として必要なStoryboardをプロジェクトに追加しておきます。
ここでは次のStoryboardを追加してます
iphone3.5inch.swift
iphone4.0inch.swift
iphone4.7inch.swift
iphone5.5inch.swift
ipad.swift
それからAppDelegate.swiftのdidFinishLaunchingWithOptionsにこんな感じで書き足します。(見づらくてごめんなさい)
import UIKit
import CoreData
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var storyboardName: NSString!
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
//機種判定
if UIDevice.currentDevice().userInterfaceIdiom == .Phone {
let myBoundSize: CGSize = UIScreen.mainScreen().bounds.size
if myBoundSize.height == CGFloat(480.0) {
storyboardName = “iphone3.5inch“
} else if myBoundSize.height == CGFloat(568.0) {
storyboardName = “iphone4.0inch“
} else if myBoundSize.height == CGFloat(667.0) {
storyboardName = “iphone4.7inch“
} else {
storyboardName = “iphone5.5inch“
}
} else if UIDevice.currentDevice().userInterfaceIdiom == .Pad {
storyboardName = “ipad“
} else {
storyboardName = “Main” //とりあえずデフォルト設定
}
// StoryBoardのインスタンス化
let storyboard: UIStoryboard! = UIStoryboard(name: storyboardName as String, bundle: nil)
// 画面の生成
let mainViewController = storyboard!.instantiateInitialViewController()
// ルートウィンドウに各Storyboardを紐付ける
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
self.window?.rootViewController = mainViewController
self.window?.makeKeyAndVisible()
return true
}
その他もろもろ続く
・
・
・
・
}
これだけです。
やってみてねー