UITabBarをコピペ実装
下記参照記事のコピペ↓
UITabBarController - Swiftサラリーマン
http://swift-salaryman.com/uitabbarcontroller.php
iOS】AppDelegate.swiftってなにしてんの?
http://qiita.com/SoyaTakahashi/items/cc8f48af792c353cd9f3
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
internal var window: UIWindow?
private var myTabBarController: UITabBarController!
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
//UIViewControllerをタブ数分作成してUITabViewControllerに埋め込む
//変数firstViewにViewController()を代入してインスタンス化。型に:UIViewControllerを指定してるので: UIViewControllerとなる
let firstView: UIViewController = ViewController()
//同上
let secondView: UIViewController = tabBarControlle()
//UIViewControllerとしてインスタンス化したclass firstViewにドット技法を使ってtabBarItemでアクセス
//その際、カッコの中でTabBarを生成する。カッコの中の引数の詳細は
//tabBarSystemIteという名前の”何か"にUITabBarSystemItemという型を指定してTabBarを定義してfeaturedは良くわかってなくて、tag: 1は多分タブの識別番号
firstView.tabBarItem = UITabBarItem(tabBarSystemItem: UITabBarSystemItem.featured, tag: 1)//アイコン
//同上
secondView.tabBarItem = UITabBarItem(tabBarSystemItem: UITabBarSystemItem.bookmarks, tag: 2)
//変数viewArrに先ほど生成したタブを配列化する
let viewArr = NSArray(objects: firstView, secondView)
//UITabBarController()をインスタンス化
myTabBarController = UITabBarController()
//ここら辺良くわかってない
myTabBarController?.setViewControllers(viewArr as! [UIViewController], animated: false)self.window!.rootViewController = myTabBarController
//.windowとmakeKeyAndVisibleが良くわかってない
self.window!.makeKeyAndVisible()
return true
}
func applicationWillResignActive(_ application: UIApplication) {
print("アプリ閉じそうな時に呼ばれる")
}
func applicationDidEnterBackground(_ application: UIApplication) {
print("アプリを閉じた時に呼ばれる")
}
func applicationWillEnterForeground(_ application: UIApplication) {
print("アプリを開きそうな時に呼ばれる")
}
func applicationDidBecomeActive(_ application: UIApplication) {
print("アプリを開いた時に呼ばれる")
}
func applicationWillTerminate(_ application: UIApplication) {
print("フリックしてアプリを終了させた時に呼ばれる")
}
}