博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
View Controller Programming Guide for iOS---(六)---Responding to Display-Related Notifications
阅读量:4486 次
发布时间:2019-06-08

本文共 3658 字,大约阅读时间需要 12 分钟。

Responding to Display-Related Notifications

响应跟显示相关的通知

When the visibility of a view controller’s view changes, the view controller calls some built-in methods to notify subclasses of the changes. You can override these methods to override how your subclass reacts to the change. For example, you can use these notifications to change the color and orientation of the status bar so that it matches the presentation style of the view that is about to be displayed.

当一个视图控制器的视图可见性发生改变时,视图控制器调用一些内建的方法来通知子类发生的改变。 你可以重写(override)这些方法来实现(override)你的子类如何对改变做出反应。 比如,你可以使用这些通知来改变状态栏的颜色和方向,使其跟即将显示的视图风格相配套。

Responding When a View Appears

一、当视图显示时做出响应

Figure 5-1 shows the sequence of events that occurs when a view controller’s view is added to a window’s view hierarchy. The  and methods give subclasses a chance to perform any additional actions related to the appearance of the view.

图5-1 显示了当一个视图控制器中的视图被添加到一个窗口视图层次里发生的一些列事件。  方法 和  方法让子类执行跟视图显示(appearance)相关的任何附加操作。 

Figure 5-1  Responding to the appearance of a view

图 5-1 对一个视图的显示(appearance)做出响应

Responding When a View Disappears

二、当视图消失时做出响应

Figure 5-2 shows the sequence of events that occurs when a view is removed from its window. When the view controller detects that its view is about to be removed or hidden, it calls the  and  methods to give subclasses a chance to perform any relevant tasks.

图5-2 显示了当一个视图从窗口移除时所发生的一系列事件。 当视图控制器检测到其视图即将被删除或隐藏时,它调用   和  方法来让子类执行任何相关任务。

Figure 5-2  Responding to the disappearance of a view

图 5-2 响应一个视图的消失

Determining Why a View’s Appearance Changed

三、确定一个视图的显示状态改变的原因

Occasionally, it can be useful to know why a view is appearing or disappearing. For example, you might want to know whether a view appeared because it was just added to a container or whether it appeared because some other content that obscured it was removed. This particular example often appears when using navigation controllers; your content controller’s view may appear because the view controller was just pushed onto the navigation stack or it might appear because controllers previously above it were popped from the stack.

有时候,知道一个视图出现或消失的原因很有用。 比如,你可能因为一个视图e刚刚被添加到一个容而器想要知道它是否被显示,或者因为遮盖(obscured)这个视图的一些内容被移除了而想知道该视图是否被显示。 该特殊例子经常在使用导航控制器时出现;你的内容控制器中的视图可能在视图控制器刚被压入导航栈时出现,或者它可能因为前一个控制器被弹出栈而出现。

The  class provides methods your view controller can call to determine why the appearance change occurred. Table 5-1 describes the methods and their usage. These methods can be called from inside your implementation of the  and methods.

 类提供了一些方法可以让视图控制器调用来确定显示状态(appearance)发生改变的原因。 表格5-1 描述了这些方法以及它们的用途。 这些方法能从 和  方法内部调用。

Table 5-1  Methods to call to determine why a view’s appearance changed

Method Name

Usage

You call this method inside your  and  methods to determine if the view controller’s view is being hidden because the view controller was removed from its container view controller.

你可以在 和  方法内部调用该方法,来确认视图控制器的视图是否正被隐藏,原因是视图控制器被从其容器视图控制器中删除。

You call this method inside your  and  methods to determine if the view controller’s view is being shown because the view controller was just added to a container view controller.

你可以在 和  方法内部调用该方法,来确定视图控制器的视图是否正被显示,因为视图控制器刚刚被加入到一个容器视图控制器。

You call this method inside your  and  methods to determine if the view controller’s view is being shown because the view controller was just presented by another view controller.

你可以在 和  方法内部调用该方法来确定视图控制器中的视图是否正被显示,因为视图控制器正被另一个视图控制器呈现(present).

You call this method inside your  and  methods to determine if the view controller’s view is being hidden because the view controller was just dismissed.

你可以在 和  方法内部调用该方法来确定视图控制器的视图是否正被隐藏,因为视图控制器刚刚被释放(dismissed)

转载于:https://www.cnblogs.com/patientAndPersist/p/3545860.html

你可能感兴趣的文章
node.js环境搭建以及入门级hello程序
查看>>
LightOJ1282 - Leading and Trailing(快速幂+数学)
查看>>
【mysql】关于checkpoint机制
查看>>
nginx总结
查看>>
如何设定ASH buffer大小
查看>>
改变调用函数的this指针方向
查看>>
【转】mq
查看>>
Java基础知识学习07-抽象类、接口、多态
查看>>
Oracle学习笔记之七(用户管理、角色与权限、导入导出等)
查看>>
linux如何挂载windows下的共享文件
查看>>
常用正则表达式
查看>>
C++学习笔记(IV) 之 表达式
查看>>
Houdini 节点参数读取输入节点的数据列表
查看>>
初识Linq to Entity
查看>>
Linux vmstat命令实战详解
查看>>
FastDFS在centos上的安装配置与使用
查看>>
HDU 1709 The Balance
查看>>
2016/7/7 设置wamp2.5 mysql密码 重点是mysql版本
查看>>
简介几种负载均衡原理
查看>>
micropython logging文档
查看>>