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

iOS如何处理设备方向变化

 2010-12-19 07:19:19 来源:WEB开发网   
核心提示:during the rotation operation, you should avoid performing any time-consuming operations there. You should also avoid replacing your entire view hierarchy with
during the rotation operation, you should avoid performing any time-consuming operations there. You should also avoid replacing your entire view hierarchy with a new set of views. There are better ways to provide unique views for different orientations, such as presenting a new view controller modally (as described in “Creating an Alternate Landscape Interface”).

For detailed information about the sequence of steps that occur during the one-step and two-step rotation processes, see “Responding to Orientation Changes.”

Declaring the Supported Interface Orientations

If the view managed by your view controller supports orientations other than the default portrait orientation, you must override the shouldAutorotateToInterfaceOrientation: method and indicate which orientations your view supports. You should always choose the orientations your view supports at design time and implement your code with those orientations in mind. There is no benefit to choosing which orientations you want to support dynamically based on runtime information. Even if you did so, you would still have to implement the necessary code to support all possible orientations, and so you might as well just choose to support the orientation or not up front.

Listing 2-4 shows a fairly typical implementation of the shouldAutorotateToInterfaceOrientation: method for a view controller that supports the default portrait orientation and the landscape-left orientation. Your own implementation of this method should be just as simple.

Listing 2-4 Implementing the shouldAutorotateToInterfaceOrientation: method

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation 

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

Tags:iOS 如何 处理

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