自定義view controller

2容器視圖控制器:custom your container view controller

* What is the role of the container and what role do its children play?

* How many children are displayed simultaneously?

* What is the relationship (if any) between sibling view controllers?

* How are child view controllers added to or removed from the container?

* Can the size or position of the children change? Under what conditions do those changes occur?

* Does the container provide any decorative or navigation-related views of its own?

* What kind of communication is required between the container and its children? Does the container need to report specific events to its children other than the standard ones defined by the UIViewController class?

* Can the appearance of the container be configured in different ways? If so, how?

* Can the size or position of the children change? Under what conditions do those changes occur?The parent-child relationship ensures that the children receive any relevant system messages.most of the real work happens during the layout and management of the contained viewsAdding a Child View Controller to Your Content

* Call the addChildViewController: method of your container view controller. This method tells UIKit that your container view controller is now managing the view of the child view controller.

* Add the child’s root view to your container’s view hierarchy.Always remember to set the size and position of the child’s frame as part of this process.

* Add any constraints for managing the size and position of the child’s root view.

*

* Call the didMoveToParentViewController: method of the child view controller.set up constraintsDo not alter the contents of the root view or any other views in the child’s view hierarchy.Removing a Child View Controller

*

* Call the child’s willMoveToParentViewController: method with the value nil.

* Remove any constraints that you configured with the child’s root view.

* Remove the child’s root view from your container’s view hierarchy.

* Call the child’s removeFromParentViewController method to finalize the end of the parent-child relationship. A child view controller should focus on its own content.Let a child view controller determine the status bar style.Let the child specify its own preferred size.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市寡润,隨后出現(xiàn)的幾起案子榴嗅,更是在濱河造成了極大的恐慌瞬内,老刑警劉巖皆尔,帶你破解...
    沈念sama閱讀 206,126評論 6 481
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件赚抡,死亡現(xiàn)場離奇詭異蠢甲,居然都是意外死亡掷匠,警方通過查閱死者的電腦和手機(jī)滥崩,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,254評論 2 382
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來讹语,“玉大人钙皮,你說我怎么就攤上這事。” “怎么了短条?”我有些...
    開封第一講書人閱讀 152,445評論 0 341
  • 文/不壞的土叔 我叫張陵导匣,是天一觀的道長。 經(jīng)常有香客問我茸时,道長贡定,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 55,185評論 1 278
  • 正文 為了忘掉前任可都,我火速辦了婚禮缓待,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘汹粤。我一直安慰自己命斧,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 64,178評論 5 371
  • 文/花漫 我一把揭開白布嘱兼。 她就那樣靜靜地躺著,像睡著了一般贤徒。 火紅的嫁衣襯著肌膚如雪芹壕。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 48,970評論 1 284
  • 那天接奈,我揣著相機(jī)與錄音踢涌,去河邊找鬼。 笑死序宦,一個胖子當(dāng)著我的面吹牛睁壁,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播互捌,決...
    沈念sama閱讀 38,276評論 3 399
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼秕噪!你這毒婦竟也來了钳降?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 36,927評論 0 259
  • 序言:老撾萬榮一對情侶失蹤腌巾,失蹤者是張志新(化名)和其女友劉穎遂填,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體澈蝙,經(jīng)...
    沈念sama閱讀 43,400評論 1 300
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡吓坚,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 35,883評論 2 323
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了灯荧。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片礁击。...
    茶點(diǎn)故事閱讀 37,997評論 1 333
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出客税,到底是詐尸還是另有隱情况褪,我是刑警寧澤,帶...
    沈念sama閱讀 33,646評論 4 322
  • 正文 年R本政府宣布更耻,位于F島的核電站测垛,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏秧均。R本人自食惡果不足惜食侮,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,213評論 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望目胡。 院中可真熱鬧锯七,春花似錦、人聲如沸誉己。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,204評論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽巨双。三九已至噪猾,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間筑累,已是汗流浹背袱蜡。 一陣腳步聲響...
    開封第一講書人閱讀 31,423評論 1 260
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留慢宗,地道東北人坪蚁。 一個月前我還...
    沈念sama閱讀 45,423評論 2 352
  • 正文 我出身青樓,卻偏偏與公主長得像镜沽,于是被迫代替她去往敵國和親敏晤。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 42,722評論 2 345

推薦閱讀更多精彩內(nèi)容