iOS-生命周期

1.应用生命周期


    Not running  →  Inactive → Active  →  Background → Suspended 


Not running 非运行状态

Inactive  前台非活动状态

Active 前台活动状态

Background 后台状态

Suspended 挂起状态


非运行状态——应用启动情景


Not running → Inactive → Active

        Not Running → Inactive    调用appliaction:didiFinishLaunchingWithOptions:方法

                                               发出UIApplicationDidFinshLanuchingNotification通知

        Inactive → Active              调用applicationDidBecomeActive:方法

                                                发出UIApplicationDidBecomeActiveNotification通知


点击Home键——应用退出情景


应用可以在后台运行或者挂起

Active  →  Inactive → Background → Suspended

        Active  →  Inactive             调用applicationWillResignActive发:方法    

                                                发出UIApplicationWillResignActiveNotification通知

       Background → Suspended     调用applicationDidEnterBackground:方法

                                                 发出UIApplicationDidEnterBackgroundNotification通知

    应用不可以在后台运行或者挂起

Active  →  Inactive → Background → Suspended →  Not running 

      Background → Suspended         调用applicationDidEnterBackground:方法    

                                                    发出UIApplicationDidEnterBackgroundNotification通知

      Suspended →  Not running        调用applicationWillTerminate:方法

                                                    发出UIApplicationWillTerminateNotification通知    


 挂起重新运行情景

Suspended  → Background  →  Inactive → Active

    Background →  Inactive        调用applicationWiillEnterForeground:方法

                                               发出UIApplicationWiillEnterForegroundNotification通知

    nactive→Active                     调用applicationDidBecomeActive:方法

                                               发出UIApplicationDidBecomeActiveNotification通知


内存清除——应用终止情景

在内存清除场景侠,应用不会调用任何方法,也不会发出应用通知


2.视图生命周期


iOS-生命周期


你可能感兴趣的:(iOS-生命周期)