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.