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:离散的内容片

Container view controllers :从其他的view controllers(child view controllers) 收集信息并呈现,

容器控制器: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.

视图控制器之间的关系定义了每个视图所需要的行为

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

两个视图控制器之间通过协议交流

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的关系: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抽象基础类

1、在后台异步读写数据

2、自动在合适的时候保存数据,并替换当前文件

处理用户交互:::::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需要处理粗粒度和细粒度的变化

粗粒度变化:根据特征变化,特征包含在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,并让其他相关的控制器 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.

你可能感兴趣的:(Programming Guide for iOS---View Controller控制器)