Programming Guide for iOS---View Controller控制器

4視圖Programming Guide for iOS---View

Use the storyboard editor to do the following:

* Add, arrange, and configure the views for a view controller.

* Connect outlets and actions; see Handling User Interactions.

* Create relationships and segues between your view controllers; see Using Segues.

* Customize your layout and views for different size classes; see Building an Adaptive Interface.

* Add gesture recognizers to handle user interactions with views; see Event Handling Guide for iOS.



1控制器 Programming Guide for iOS---View Controller

主題:View Management—data marshaling——user interactions———resource management——adaptivity

UIAccessibilityScreenChangedNotificationSupporting Accessibility? 支持可訪問

手勢Escape退出

Content view controllers:離散的內(nèi)容片

Container view controllers :從其他的view controllers(child view controllers) 收集信息并呈現(xiàn)炸茧,

容器控制器:does not manage the content of its children. It manages only the root view, sizing and placing it according to the container’s design.

to combine the content from multiple view controllers into a single user interface.

視圖控制器之間的關(guān)系定義了每個視圖所需要的行為

The root view controller is the anchor of the view controller hierarchy.

window 的屬性

管理視圖層to manage a hierarchy of views

每個視圖控制器 都是一個獨立的島嶼? ? Make Each View Controller an Island

兩個視圖控制器之間通過協(xié)議交流

The exact type of the delegate object is unimportant. All that matters is that it implements the methods of the protocol

A UIDocument object is one way to manage your data separately from your view controllers.

The view controller might store a copy of any data it receives to make it easier to update views, but the document still owns the true data.

UIViewController與UIDocument的關(guān)系:no default relationship exists between the two

the view controller should only cache information from the document for efficiency. The actual data still belongs to the document object.

UIDocument抽象基礎(chǔ)類

1腻豌、在后臺異步讀寫數(shù)據(jù)

2、自動在合適的時候保存數(shù)據(jù),并替換當(dāng)前文件

處理用戶交互:::::view controllers rarely handle touch events directly

1偶翅、 Action methods

2、notifications

3被饿、View controllers act as a data source or delegate for another object

remove references to objects that you no longer need or can recreate easily later

remove references to objects刪除的對象的引用

need to handle coarse-grained changes and fine-grained changes需要處理粗粒度和細(xì)粒度的變化

粗粒度變化:根據(jù)特征變化,特征包含在display scale医咨、horizontal size 、vertical size.

rotates an iPhone from portrait to landscape

the size class might not change but the screen dimensions usually change.

View controllers can make additional adjustments as needed.

----updates the layout information架诞,并讓其他相關(guān)的控制器 know abut the layout changes

the layout process

Updates the trait collections of the view controller and its views, as needed; see When Do Trait and Size Changes Happen?

Calls the view controller’s viewWillLayoutSubviews method.

Calls the containerViewWillLayoutSubviews method of the current UIPresentationController object.

Calls the layoutSubviews method of view controller’s root view.

The default implementation of this method computes the new layout information using the available constraints. The method then traverses the view hierarchy and calls layoutSubviews for each subview.

Applies the computed layout information to the views.

Calls the view controller’s viewDidLayoutSubviews method.

Calls the containerViewDidLayoutSubviews method of the current UIPresentationController object.

Here are some tips for managing your layout effectively:

* Use Auto Layout. The constraints you create using Auto Layout are a flexible and easy way to position your content on different screen sizes.

* Take advantage of the top and bottom layout guides. Laying out content to these guides ensures that your content is always visible. The position of the top layout guide factors in the height of the status bar and navigation bar. Similarly, the position of the bottom layout guide factors in the height of a tab bar or toolbar.

* Remember to update constraints when adding or removing views. If you add or remove views dynamically, remember to update the corresponding constraints.

* Remove constraints temporarily while animating your view controller’s views. When animating views using UIKit Core Animation, remove your constraints for the duration of the animations and add them back when the animations finish. Remember to update your constraints if the position or size of your views changed during the animation.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末拟淮,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子侈贷,更是在濱河造成了極大的恐慌惩歉,老刑警劉巖,帶你破解...
    沈念sama閱讀 218,858評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件俏蛮,死亡現(xiàn)場離奇詭異撑蚌,居然都是意外死亡,警方通過查閱死者的電腦和手機搏屑,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,372評論 3 395
  • 文/潘曉璐 我一進店門争涌,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人辣恋,你說我怎么就攤上這事亮垫。” “怎么了伟骨?”我有些...
    開封第一講書人閱讀 165,282評論 0 356
  • 文/不壞的土叔 我叫張陵饮潦,是天一觀的道長。 經(jīng)常有香客問我携狭,道長继蜡,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,842評論 1 295
  • 正文 為了忘掉前任逛腿,我火速辦了婚禮稀并,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘单默。我一直安慰自己碘举,他們只是感情好,可當(dāng)我...
    茶點故事閱讀 67,857評論 6 392
  • 文/花漫 我一把揭開白布搁廓。 她就那樣靜靜地躺著引颈,像睡著了一般。 火紅的嫁衣襯著肌膚如雪枚抵。 梳的紋絲不亂的頭發(fā)上线欲,一...
    開封第一講書人閱讀 51,679評論 1 305
  • 那天,我揣著相機與錄音汽摹,去河邊找鬼李丰。 笑死,一個胖子當(dāng)著我的面吹牛逼泣,可吹牛的內(nèi)容都是我干的趴泌。 我是一名探鬼主播舟舒,決...
    沈念sama閱讀 40,406評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼嗜憔!你這毒婦竟也來了秃励?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,311評論 0 276
  • 序言:老撾萬榮一對情侶失蹤吉捶,失蹤者是張志新(化名)和其女友劉穎夺鲜,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體呐舔,經(jīng)...
    沈念sama閱讀 45,767評論 1 315
  • 正文 獨居荒郊野嶺守林人離奇死亡币励,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,945評論 3 336
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了珊拼。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片食呻。...
    茶點故事閱讀 40,090評論 1 350
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖澎现,靈堂內(nèi)的尸體忽然破棺而出仅胞,到底是詐尸還是另有隱情,我是刑警寧澤剑辫,帶...
    沈念sama閱讀 35,785評論 5 346
  • 正文 年R本政府宣布干旧,位于F島的核電站,受9級特大地震影響妹蔽,放射性物質(zhì)發(fā)生泄漏莱革。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,420評論 3 331
  • 文/蒙蒙 一讹开、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧捐名,春花似錦旦万、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,988評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至贺归,卻和暖如春淆两,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背拂酣。 一陣腳步聲響...
    開封第一講書人閱讀 33,101評論 1 271
  • 我被黑心中介騙來泰國打工秋冰, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人婶熬。 一個月前我還...
    沈念sama閱讀 48,298評論 3 372
  • 正文 我出身青樓剑勾,卻偏偏與公主長得像埃撵,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子虽另,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 45,033評論 2 355

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

  • **2014真題Directions:Read the following text. Choose the be...
    又是夜半驚坐起閱讀 9,509評論 0 23
  • ViewsBecause view objects are the main way your applicati...
    梁光飛閱讀 604評論 0 0
  • 常聽到有人抱怨世態(tài)炎涼暂刘,人心冷漠,但其實捂刺,這個世界并沒有你想象得那么糟谣拣。 人生,總有一些不期而遇的...
    memory89閱讀 198評論 0 0
  • 周五度過了今年以來最忙的一天族展。 剛上班接到學(xué)校群通知森缠,下周交畢業(yè)論文的題綱。 下午國家基金專家開會苛谷。 工作辅鲸、學(xué)習(xí)的...
    蕊蕊啊閱讀 219評論 0 1
  • 那年独悴,我們喜歡一起沿著跑道繞著圈。任憑熱浪打在臉上.吹在心里.一圈圈不知疲憊的走著.好似一直不停歇的走就會把...
    九錐加三閱讀 372評論 0 0