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)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

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

友情鏈接更多精彩內(nèi)容