iOS-生命週期

1.應用生命週期


    Not running  →  Inactive → Active  →  Background → Suspended app


Not running 非運行狀態spa

Inactive  前臺非活動狀態生命週期

Active 前臺活動狀態內存

Background 後臺狀態it

Suspended 掛起狀態io


非運行狀態——應用啓動情景


Not running → Inactive → Active後臺

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

                                               發出UIApplicationDidFinshLanuchingNotification通知im

        Inactive → Active              調用applicationDidBecomeActive:方法img

                                                發出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.視圖生命週期


相關文章
相關標籤/搜索