126
136

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AppDelegate,UIViewController,UIViewのライフサイクル/iOS/Swift

Last updated at Posted at 2015-10-07

AppDelegate.swift

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
        return true
    }

    func applicationWillResignActive(application: UIApplication) {
        print("AppDelegate/WillResignActive/アプリ閉じる前")
    }

    func applicationDidEnterBackground(application: UIApplication) {
        print("AppDelegate/DidEnterBackground/アプリを閉じた時")
    }

    func applicationWillEnterForeground(application: UIApplication) {
        print("AppDelegate/WillEnterForeground/アプリを開く前")
    }

    func applicationDidBecomeActive(application: UIApplication) {
        print("AppDelegate/DidBecomeActive/アプリを開いた時")
    }

    func applicationWillTerminate(application: UIApplication) {
        print("AppDelegate/WillTerminate/アプリ終了時(フリック)")
    }
    

UIViewController

 override func viewDidLoad() {
  super.viewDidLoad()
  print("ViewController/viewDidLoad/インスタンス化された直後(初回に一度のみ)")

 }
    
 override func viewWillAppear(animated: Bool) {
  super.viewDidDisappear(animated)
  print("ViewController/viewWillAppear/画面が表示される直前")
 }
    
 override func viewDidAppear(animated: Bool) {
  super.viewDidAppear(animated)
  print("ViewController/viewDidAppear/画面が表示された直後")
 }
    
 override func viewWillDisappear(animated: Bool) {
  super.viewWillDisappear(animated)
  print("ViewController/viewWillDisappear/別の画面に遷移する直前")
 }
    
 override func viewDidDisappear(animated: Bool) {
  super.viewDidDisappear(animated)
  print("ViewController/viewDidDisappear/別の画面に遷移した直後")
 }

 override func didReceiveMemoryWarning() {
  super.didReceiveMemoryWarning()
  print("ViewController/didReceiveMemoryWarning/メモリが足りないので開放される")
 }



UIView

override func willMoveToSuperview(newSuperview: UIView?) {
	print("UIView/willMoveToSuperview/新しいSuperviewに対してaddSubviewされる前")
}

override func didMoveToSuperview() {
    print("UIView/didMoveToSuperview/新しいSuperviewにaddSubviewされた時")
}
    
override func willMoveToWindow(newWindow: UIWindow?) {
    print("UIView/willMoveToWindow/新しいWindowに対してaddSubviewされる前")
}

override func didMoveToWindow() {
    print("UIView/didMoveToWindow/新しいWindowに対してaddSubviewされた時")
}

override func didAddSubview(subview: UIView) {
	print("UIView/didAddSubview/自分自身に他のviewがsubviewとして追加されたとき")
}

override func willRemoveSubview(subview: UIView) {
	print("UIView/willRemoveSubview/自分自身のsubviewsから他のviewが取り除かれようとしているとき")
}


android版

126
136
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
126
136

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?