WEB开发网
开发学院手机开发iPhone 开发 iOS如何处理设备方向变化 阅读

iOS如何处理设备方向变化

 2010-12-19 07:19:19 来源:WEB开发网   
核心提示:autoresizing properties of views and how they affect the view, see View Programming Guide for iOS.Responding to Orientation ChangesWhen the orientation of a dev
autoresizing properties of views and how they affect the view, see View Programming Guide for iOS.

Responding to Orientation Changes

When the orientation of a device changes, view controllers can respond by making a corresponding change to the orientation of their view. If the new orientation is supported, the view controller generates notifications as it makes the change to give your code a chance to respond. Rotation notifications can occur as a one-step or two-step process.

The reason you might want to respond to orientation changes is to make adjustments to your view hierarchy. For example, you might use these notifications to make the following types of changes:

Show or hide views that are specific to a particular orientation.

Adjust the position or size of views based on the new orientation.

Update other parts of your application to reflect the orientation change.

Whenever possible, the UIKit framework uses the one-step rotation process to rotate your views. However, whether it actually uses the one-step or two-step process is up to you. There are methods used by the two-step process that are not used by the one-step process, and vice versa; if you override any of the one-step methods, the one-step process is used. If you override only methods that are used by the two-step process, that process is used. The following sections describe the methods associated with each process. You can also find information about these methods (including whether they trigger the one-step or two-step process) in UIViewController Class Reference.

Responding to Orientation Changes in One Step

In iOS 3.0 and later, you can use one-step rotation methods to make changes just before and just after the orientation change occurs. During this process, the following sequence of events occurs:

The window detects that a change in the device orientation has

上一页  1 2 3 4 5 6 7 8 9 10  下一页

Tags:iOS 如何 处理

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接