viewWillAppear:
Called
when the view is about to made visible. Default does
nothing視圖即將可見時(shí)調(diào)用廓俭。默認(rèn)情況下不執(zhí)行任何操作
viewDidAppear:
Called
when the view has been fully transitioned onto the screen. Default
does nothing視圖已完全過渡到屏幕上時(shí)調(diào)用
viewWillDisappear:
Called
when the view is dismissed, covered or otherwise hidden. Default
does nothing視圖被駁回時(shí)調(diào)用杂腰,覆蓋或以其他方式隱藏。默認(rèn)情況下不執(zhí)行任何操作
viewDidDisappear:
Calledafter the view was dismissed, covered or otherwise hidden. Defaultdoesnothing視圖被駁回后調(diào)用砾肺,覆蓋或以其他方式隱藏。默認(rèn)情況下不執(zhí)行任何操作loadView;Thisis where subclasses should create their custom view hierarchy ifthey aren't using a nib. Should never be calleddirectly.這是當(dāng)他們沒有正在使用nib視圖頁面匈挖,子類將會(huì)創(chuàng)建自己的自定義視圖層稠氮。絕不能直接調(diào)用。
viewDidLoad;Calledafter the view has been loaded. For view controllers created incode, this is after -loadView. For view controllers unarchived froma nib, this is after the view is set.
在視圖加載后被調(diào)用茉盏,如果是在代碼中創(chuàng)建的視圖加載器鉴未,他將會(huì)在loadView方法后被調(diào)用,如果是從nib視圖頁面輸出鸠姨,他將會(huì)在視圖設(shè)置好后后被調(diào)用铜秆。
「initWithNibName:
bundle:」載入nib檔案來初始化「loadView」載入視圖「viewDidLoad」在載入視圖至內(nèi)存后會(huì)呼叫的方法「viewDidUnload」在視圖從內(nèi)存中釋放后會(huì)呼叫的方法
(當(dāng)內(nèi)存過低,釋放一些不需要的視圖時(shí)調(diào)用)
「viewWillAppear」當(dāng)收到視圖在視窗將可見時(shí)的通知會(huì)呼叫的方法
「viewDidAppear」當(dāng)收到視圖在視窗已可見時(shí)的通知會(huì)呼叫的方法
「viewWillDisappear」當(dāng)收到視圖將去除讶迁、被覆蓋或隱藏于視窗時(shí)的通知會(huì)呼叫的方法
「viewDidDisappear」當(dāng)收到視圖已去除连茧、被覆蓋或隱藏于視窗時(shí)的通知會(huì)呼叫的方法
「didReceiveMemoryWarning」收到系統(tǒng)傳來的內(nèi)存警告通知后會(huì)執(zhí)行的方法
「shouldAutorotateToInterfaceOrientation」是否支持不同方向的旋轉(zhuǎn)視圖
「willAnimateRotationToInterfaceOrientation」在進(jìn)行旋轉(zhuǎn)視圖前的會(huì)執(zhí)行的方法(用于調(diào)整旋轉(zhuǎn)視圖之用)
當(dāng)一個(gè)視圖控制器被創(chuàng)建,并在屏幕上顯示的時(shí)候巍糯。
代碼的執(zhí)行順序
1啸驯、alloc創(chuàng)建對(duì)象,分配空間
2祟峦、init (initWithNibName) 初始化對(duì)象罚斗,初始化數(shù)據(jù)
3、loadView從nib載入視圖宅楞,通常這一步不需要去干涉针姿。除非你沒有使用xib文件創(chuàng)建視圖
4、viewDidLoad載入完成咱筛,可以進(jìn)行自定義數(shù)據(jù)以及動(dòng)態(tài)創(chuàng)建其他控件
5搓幌、viewWillAppear視圖將出現(xiàn)在屏幕之前,馬上這個(gè)視圖就會(huì)被展現(xiàn)在屏幕上了
6迅箩、viewDidAppear視圖已在屏幕上渲染完成 當(dāng)一個(gè)視圖被移除屏幕并且銷毀的時(shí)候的執(zhí)行順序溉愁,這個(gè)順序差不多和上面的相反
1、viewWillDisappear視圖將被從屏幕上移除之前執(zhí)行
2、viewDidDisappear視圖已經(jīng)被從屏幕上移除拐揭,用戶看不到這個(gè)視圖了
3撤蟆、dealloc視圖被銷毀,此處需要對(duì)你在init和viewDidLoad中創(chuàng)建的對(duì)象進(jìn)行釋放