App and Environment
Manage life-cycle events and your app’s UI scenes, and get information about traits and the environment in which your app runs.
--app和环境用于管理生命周期事件和app的UI scenes,并获取有关特性和app运行环境的信息。
Overview --概览
In iOS 13 and later, the user can create and manage multiple instances of your app's user interface simultaneously, and switch between them using the app switcher. On iPad, the user can also display multiple instances of your app side by side. Each instance of your UI displays different content, or displays the same content in a different way. For example, the user can display one instance of the Calendar app showing a specific day, and another showing an entire month.
--在iOS 13及更高版本中,用户可以同时创建和管理app的用户界面的多个实例,并使用app切换器在它们之间进行切换。在iPad上,用户还可以并排显示app的多个实例。用户界面的每个实例都显示不同的内容,或者以不同的方式显示相同的内容。例如,用户可以显示日历应用程序的一个实例,其中显示特定的一天,而另一个实例则显示整个月。
UIKit communicates details about the current environment using trait collections, which reflect a combination of device settings, interface settings, and user preferences. For example, you use traits to detect whether Dark Mode is active for the current view or view controller. Consult the current trait collection of your UIView
or UIViewController
object when you want to customize its contents based on the current environment. Adopt the UITraitEnvironment
protocol in other objects when you want them to receive trait notification changes.
--UIKit使用trait集合传递有关当前环境的详细信息,trait集合反映设备设置、界面设置和用户首选项的组合。例如,可以使用traits来检测当前视图或视图控制器的暗模式是否处于活动状态。如果想要基于当前环境 "来自定义" UIView或UIViewController对象的 "内容",请参考其"当前特征集合"。如果希望其他对象接收trait通知更改,请在其中采用UITraitEnvironment协议。
Topics --专题
Life Cycle --生命周期
Managing Your App's Life Cycle --管理app的生命周期
Respond to system notifications when your app is in the foreground or background, and handle other significant system-related events.
Responding to the Launch of Your App --响应app的启动周期
Initialize your app’s data structures, prepare your app to run, and respond to any launch-time requests from the system.
The centralized point of control and coordination for apps running in iOS.
protocol UIApplicationDelegate
A set of methods that you use to manage shared behaviors for your app.
Scenes --scenes
Manage multiple instances of your app’s UI simultaneously, and direct resources to the appropriate instance of your UI.
Device Environment --设备环境
class UIDevice
--用于描述当前设备(手机)的类
A representation of the current device.
class UIStatusBarManager
--手机状态栏的类
An object describing the configuration of the status bar.
Adaptivity --自适应性
Responding to Changing Display Modes on Apple TV
Change images and resources dynamically when the screen gamut on your device changes.
class UITraitCollection
--特征集合,用于描述当前设备、用户、界面的环境
The iOS interface environment for your app, defined by traits such as horizontal and vertical size class, display scale, and user interface idiom.
A set of methods that makes the iOS interface environment available to your app.
protocol UIAdaptivePresentationControllerDelegate
A set of methods that, in conjunction with a presentation controller, determine how to respond to trait changes in your app.
A set of methods for adapting the contents of your view controllers to size and trait changes.
Guided Access --引导访问
protocol UIGuidedAccessRestrictionDelegate
A set of methods you use to add custom restrictions for the Guided Access feature in iOS.
Returns the restriction state for the specified guided access restriction.
Architecture --设备的硬件架构
Updating Your App from 32-Bit to 64-Bit Architecture
Ensure that your app behaves as expected by adapting it to support later versions of the operating system.
Creates the application object and the application delegate and sets up the event cycle.
See Also
App Structure
Documents, Data, and Pasteboard
Organize your app's data and share that data on the pasteboard.
Manage the images, strings, storyboards, and nib files that you use to implement your app's interface.
Extend your app's basic functionality to other parts of the system.
Share data through Handoff, support universal links into your app's content, and display activity-based services to the user.
Create a version of your iPad app that users can run on a Mac device.