Responding to the Launch of Your App Initialize your app’s data structures, prepare your app to run, and respond to any launch-time requests from the ...

 Responding to the Launch of Your App

  Initialize your app’s data structures, prepare your app to run, and respond to any launch-time requests from the system.



  The system launches your app when the user taps your app’s icon on the Home screen. If your app requested specific events, the system might also launch your app in the background to handle those events. For a scene-based app, the system similarly launches the app when one of your scenes needs to appear onscreen or do some work.


  All apps have an associated process, represented by the UIApplication object. Apps also have an app delegate object—an object that conforms to the UIApplicationDelegateprotocol—whose job is to respond to important events happening within that process. Even a scene-based app uses an app delegate to manage fundamental events like launch and termination. At launch time, UIKit automatically creates the UIApplication object and your app delegate. It then starts your app’s main event loop.


 Provide a Launch Storyboard

  When the user first launches your app on a device, the system displays your launch storyboard until your app is ready to display its UI. Displaying the launch storyboard assures the user that your app launched and is doing something. If your app initializes itself and readies its UI quickly, the user may see your launch storyboard only briefly.

  當用戶第一次在設備上啟動你的應用程式時,系統會顯示啟動故事板,直到程式準備好它的UI.顯示故事板的目的是向用戶保證你的應用程式已經啟動,而且正在運行。 如果你的應用程式初始化的速度和準備的過程非常快,那用戶可能只能短暫的看到你的啟動故事板。

  Xcode projects automatically include a default launch storyboard for you to customize, and you can add more launch storyboards as needed. To add new launch storyboards to your project, do the following:


  1. Open your project in Xcode.

  2. Select File > New > New File.

  3. Add a Launch Screen resource to your project.

  Add views to your launch storyboard, and use Auto Layout constraints to size and position those views so that they adapt to the underlying environment. For example, you might create a splash screen with a solid-color background and a fixed-size image of your company logo or other content. Always create a final version of the interface you want. Never include temporary content or content that requires localization. UIKit displays exactly what you provide, using your constraints to fit your views into the available space.



  In iOS 13 and later, always provide a launch storyboard for your app. Don’t use static launch images.


  Initialize Your App's Data Structures

  Put your app's launch-time initialization code in one or both of the following methods:


  UIKit calls these methods at the beginning of your app’s launch cycle. Use them to:


  • Initialize your app's data structures.

  • 初始化應用程式的結構
  • Verify that your app has the resources it needs to run. 

  • 驗證應用程式運行所需要的資源
  • Perform any one-time setup when your app is launched for the first time. For example, install templates or user-modifiable files in a writable directory; see Performing One-Time Setup for Your App

  • 在應用程式第一次啟動時執行任何一次性設置,例如:在可讀寫的目錄中安裝模板或用戶可修改的文件。
  • Connect to any critical services that your app uses. For example, connect to the Apple Push Notification service if your app supports remote notifications.

  • 連接應用程式使用的任何關鍵服務。例如:如果你的應用程式支持遠程推送通知,會連接到APNS.
  • Check the launch options dictionary for information about why your app was launched; see Determine Why Your App Was Launched.

  • 檢查啟動項字典信息。

  For apps that aren't scene-based, UIKit loads your default user interface automatically at launch time. Use the application(_:didFinishLaunchingWithOptions:) method to make additional changes to that interface before it appears onscreen. For example, you might install a different view controller to reflect what the user was doing the last time they used the app.


  Move Long-Running Tasks off the Main Thread

  When the user launches your app, make a good impression by launching quickly. UIKit doesn't present your app's interface until after the application(_:didFinishLaunchingWithOptions:) method returns. Performing long-running tasks in that method or your application(_:willFinishLaunchingWithOptions:) method might make your app appear sluggish to the user. Returning quickly is also important when launching to the background, because your app’s background execution time is limited. 


  Move tasks that are not critical to your app’s initialization out of the launch-time sequence. For example:


  • Defer the initialization of features that are not needed immediately.

  • 推遲不需要的特性初始化。
  • Move important, long-running tasks off your app’s main thread. For example, run them asynchronously on a global dispatch queue.

  • 將重要的長時間運行的任務移出應用程式的主線程。例如:在全局調度隊列中非同步運行他們。

 Determine Why Your App Was Launched

  When UIKit launches your app, it passes along a launch options dictionary to your application(_:willFinishLaunchingWithOptions:) and application(_:didFinishLaunchingWithOptions:) methods with information about why your app was launched. The keys in that dictionary indicate important tasks to perform immediately. For example, they might reflect actions that the user started elsewhere and want to continue in your app. Always check the contents of the launch options dictionary for keys that you expect, and respond appropriately to their presence.

  當UIkit啟動你的應用程式時,它會傳遞一個啟動項字典給你的應用程式application(_:willFinishLaunchingWithOptions:) and application(_:didFinishLaunchingWithOptions:)方法,其中包含了為什麼啟動。字典中的鍵標識立即執行的重要任務。例如:它們可能反應用戶在其他地方啟動的操作,並希望在應用程式中繼續執行。始終檢查啟動項字典的內容,查找您期望的鍵,並對它們做出適當的響應。


  For a scene-based app, examine the options passed to the application(_:configurationForConnecting:options:) method to determine why your scene was created.


  Listing 1 shows the app delegate method for an app that handles background location updates. When the location key is present, the app starts location updates immediately, instead of deferring them until later. Starting location updates allows the Core Location framework to deliver the new location event.


class AppDelegate: UIResponder, UIApplicationDelegate, 
               CLLocationManagerDelegate {
   let locationManager = CLLocationManager()
   func application(_ application: UIApplication,
              didFinishLaunchingWithOptions launchOptions:
              [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
      // If launched because of new location data,
      //  start the visits service right away.
      if let keys = launchOptions?.keys {
         if keys.contains(.location) {
            locationManager.delegate = self
      return true
   // other methods…

  The system doesn’t include a key unless your app supports the corresponding feature. For example, the system doesn’t include the remoteNotification key for an app that doesn’t support remote notifications. 

  For a list of launch option keys and information about how to handle them, see UIApplication.LaunchOptionsKey.




  • 問題描述:今天在虛擬機下進行startup的操作,但是沒有起來,系統報錯:ORA-00845: MEMORY_TARGET not supported on this system 1.startup啟動,MEMORY_TARGET啟動不起來在系統中,Oracle總共可以使用的共用記憶體大小,這個參數 ...
  • MySQL資料庫備份和恢復 [toc] 備份恢復概述 為什麼要備份 災難恢復:硬體故障、軟體故障、自然災害、黑客攻擊、誤操作測試等數據丟失場景 備份註意要點 能容忍最多丟失多少數據 恢複數據需要在多長時間內完成 需要恢復哪些數據 還原要點 做還原測試,用於測試備份的可用性 還原演練 備份類型: 完全 ...
  • 問題描述:本來配置好的DG第二天重啟之後,發現主備庫數據不能同步,在主庫上執行日誌切換以及創建表操作都傳不到備庫上,造成這種錯誤的原因是主庫實例斷掉後造成備庫日誌與主庫無法實時接收 主庫:orcl 備庫:orclstd 說明:啟動之前主備庫都要開啟監聽,否則接收不到數據 1.在主庫上:啟動主庫,切換 ...
  • [toc] 一、準備工作 先來一段偽代碼,首先你能看懂麽? 繼續做以下的前期準備工作: 新建一個測試資料庫TestDB; 創建測試表table1和table2; 插入測試數據; 準備工作做完以後,table1和table2看起來應該像下麵這樣: 準備SQL邏輯查詢測試語句 Oracle SQL語句執 ...
  • https://www.jianshu.com/p/faa5e852b76b https://bbs.csdn.net/topics/70039385 https://www.runoob.com/sqlite/sqlite-insert.html http://c.biancheng.net/vi ...
  • 基本語法如下 sqlite> select * from tb_user; sqlite> select userid,username from tb_user; 格式化的查詢輸出 sqlite> .header on sqlite> .mode column sqlite> select * f ...
  • 概述&背景 MySQL一直被人詬病沒有實現HashJoin,最新發佈的8.0.18已經帶上了這個功能,令人欣喜。有時候在想,MySQL為什麼一直不支持HashJoin呢?我想可能是因為MySQL多用於簡單的OLTP場景,並且在互聯網應用居多,需求沒那麼緊急。另一方面可能是因為以前完全靠社區,這種演進 ...
  • SQL:Structured Quety Language SQL SERVER是一個以客戶/伺服器(c/s)模式訪問、使用Transact-SQL語言的關係型資料庫管理子系統(RDBMS) DBMS :Database Management System資料庫管理系統 資料庫:程式用來存取數據的 ...
  • 微信公眾號: "Dotnet9" ,網站: "Dotnet9" ,問題或建議: "請網站留言" , 如果對您有所幫助: "歡迎贊賞" 。 .NET CORE(C ) WPF 值得推薦的動畫菜單設計 閱讀導航 1. 本文背景 2. 代碼實現 3. 本文參考 4. 源碼 1. 本文背景 YouTube上 ...
  • 1. HttpRequest對象 伺服器接收到http協議的請求後,會根據報文創建HttpRequest對象,這個對象不需要我們創建,直接使用伺服器構造好的對象就可以。視圖的第一個參數必須是HttpRequest對象,在django.http模塊中定義了HttpRequest對象的API。 1.1 ...
  • SpringMVC 攔截器 Spring MVC也可以使用攔截器對請求進行攔截處理,可以自定義攔截器來實現特定的功能,自定義的攔截器可以實現HandlerInterceptor介面中的三個方法,也可以繼承HandlerInterceptorAdapter 適配器類按照需要那個方法,就實現哪個方法 過 ...
  • 1. JDBC介紹 JDBC(Java DataBase Connectivity),即Java資料庫的連接。JDBC是一種用於執行SQL語句(DML,DDL,DQL)的Java API,可以為多種關係資料庫(oracle,mysql,sqlserver)提供統一訪問,它由一組用Java語言編寫的類 ...
  • [toc] 一、入門 1、Spring Boot簡介 簡化Spring應用開發的一個框架 整個Spring技術棧的整合 J2EE開發的一站式解決方案 2、微服務 Martin Fowler 微服務是一種架構風格 一個應用應該是一組小型服務:可以通過HTTP的方式進行互通 每一個功能元素最終都是一個可 ...
  • 首先如果直接使用 root 用戶來啟動 tomcat 的話,是可以正常啟動的。 但是我們在 Linux 中使用普通用戶啟動 tomcat 報瞭如下錯誤 原因是沒有在 setclasspath.sh 上設置 JAVA_HOME 和 JRE_HOME。 解決辦法: 打開 setclasspath.sh ...
  • 線上實時轉換 需要 .babelrc中: 項目中main.js配置: 前提是安裝對應的包 自己寫的要運行的為app.js,這樣配置後會在運行main.js是自動轉為es5並執行 通過配置手動轉換 需要 安裝babel後 運行 src為自己寫的es6目錄文件,dist為轉碼後的es5文件,沒有則創建 ...
  • 假如有兩個文件:app.js和config.js app.js為主文件要去引用config這個模塊 以前學習node時使用的模塊導出: es6中的模塊導出 方法一 兩種可以混合使用 方法二 通過 export 導出的成員必須通過解構賦值按需載入 或者通過 的形式載入所有通過 export 關鍵字導出 ...
  • 不做解釋,代碼一看就懂 app.js config.js ...
  • 對babel進行複習