iOS应用生命周期及Viewcontroller生命周期

(一)APP应用有以下几种状态:

Not running:应用未运行;

InActive:应用在前台未活动;

Active:应用处于活动状态;

Background:运行在background和正在执行代码;

suspend:运行在background和未执行代码;

当应用启动时:

由not running-(1)->InActive-(2)->Active.

(1):调用application:didFinishLaunchingWithOptions

(2):调用applicationDidBecomeActive

当应用切换APP时:

由Active-(1)->InActive-(2)->running。

(1):调用applicationWillResignActive

(2):调用applicationDidEnterBackground

切换回来时

由running-(1)->InActive-(2)->Active

(1):调用applicationWillEnterForeground

(2):调用applicationDidBecomeActive

(二)ViewController生命周期

alloc-->init-->loadView-->viewDidLoad-->viewWillAppear-->viewDidAppear

Viewcontroller被销毁时:

viewWillDisappear-->viewDidDisappear-->dealloc

你可能感兴趣的:(iOS应用生命周期及Viewcontroller生命周期)