Chapter 17 Autorotation, Popover Controller, and Modal View Controllers

1.There are two distinct orientations in iOS: device orientation and interface orientation.

The device orientation represents the physical orientation of the device, whether it is right-side up, upside down, rotated left, rotated right, on its face, or on its back. You can access the device orientation through the UIDevice class’s orientation property.

The interface orientation, by contrast, is a property of the running application. The following list shows all of the possible interface orientations:

UIInterfaceOrientationPortrait   The Home button is below the screen

UIInterfaceOrientationPortraitUpsideDown   The Home button is above the screen.

UIInterfaceOrientationLandscapeLeft  The device is on its side and the home button is to the right of the screen.

UIInterfaceOrientationLandscapeRight  The device is on its side and the Home button is to the left of the screen.

When the application’s interface orientation changes, the size of the window for the application also changes. The window will take on its new size and will rotate its view hierarchy. The views in the hierarchy will lay themselves out again according to their constraints.

2. When writing code to respond to a change in orientation, you override the UIViewController method willAnimateRotationToInterfaceOrientation:duration:. The message willAnimateRotationToInterfaceOrientation:duration: is sent to a view controller when the interface orientation successfully changes. The new interface orientation value is in the first argument to this method.

3. When you write code that changes something about a view (like its frame or whether it is hidden) in this method, those changes are animated. The duration argument tells you how long that animation will take. If you are doing some other work on rotation that does not involve views, or you just do not want the views to animate their changes, you can override the willRotateToInterfaceOrientation:duration: method in your view controller. This method gives you the same information at the same time, but your views are not automatically animated.

Additionally, if you want to do something after the rotation is completed, you can override didRotateFromInterfaceOrientation: in your view controller.  This method’s argument is the previous interface orientation before the rotation occurred. You can always ask a view controller for its current orientation by sending it the message interfaceOrientation.

4. On the iPhone or iPod touch, a modal view controller takes over the entire screen. This is the default behavior and the only possibility on these  devices. On the iPad, you have two additional options: a form sheet style and a page sheet style. You can change the presentation of the modal view controller by setting its modal PresentationStyle property to a pre-defined constant UIModalPresentationFormSheet or UIModalPresentationPageSheet.

5. In addition to changing the presentation style of a modal view controller, you can change the animation that places it on screen. Like presentation styles, there is  a view controller property(modalTransitionStyle) that you can set with a pre-defined constant. By default, the animation will slide the modal view controller up from the bottom of the screen. You can also have the view controller fade in, flip in, or appear underneath a page curl. The various transition styles are:

UIModalTransitionStyleCoverVertical slides up from the bottom

UIModalTransitionStyleCrossDissolve fades in

UIModalTransitionStyleFlipHorizontal flips in with a 3D effect

UIModalTransitionStylePartialCurl presenting view controller is peeled up revealing the modal view controller

时间: 2024-12-31 03:44:24

Chapter 17 Autorotation, Popover Controller, and Modal View Controllers的相关文章

iOS Programming Autorotation, Popover Controllers, and Modal View Controllers

iOS Programming Autorotation, Popover Controllers, and Modal View Controllers? 自动旋转,Popover 控制器,Modal view controller? 1.? In this chapter, you are going to make four changes to Homepwner's behavior that will tailor the app's behavior to whatever dev

【IOS笔记】Using View Controllers in Your App

参考:http://www.cnblogs.com/patientAndPersist/p/3279645.html Using View Controllers in Your App Whether you are working with view controllers provided by iOS, or with custom controllers you’ve created to show your app’s content, you use a similar set o

iPad keyboard will not dismiss if modal view controller presentation style is UIModalPresentationFor

在ipad上present 一个 navigation controller 时,present后弹出的keyboard,不能够 dismiss 掉.即使 textfield resignFirstResponder,keyboard也不会消失. Problem: 在iPad keyboard上发现一个问题,当viewController在navigation controller下以模态视图弹出,并且navigationController.modalPresentationStyle = U

iOS开发报错之attempt to dismiss modal view controller whose view does not currently appear

刚才遇到一个问题,现在在这就当纪录一下,大家有遇到的能快速找到原因,分享一下啊. 在APP中,需要用户登录后才能使用,所以我通过更改APP的[UIApplicationsharedApplication].keyWindow.rootViewController来控制界面的跳转. 在使用过程中出现如下问题: 1.登录成功后点击注销按钮,弹出注销提示框UIAlertView: 2.注销成功后重新登录: 3.再次点击注销不再弹出UIAlertView. 提示如下警告: 点击注销按钮执行更改rootv

Chapter 17. Objects and Inheritance(对象与继承)

SELECT DISTINCT fa.application_short_name 模块,                 b.responsibility_name 职责名称, fa.application_name 应用产品,                 b.responsibility_key 责任关键字, b.description 说明,                 DECODE (b.data_group_id, 0, '标准', '') 数据组,              

chapter 17

Chapter 17 Input,Output,and Files ## An Overview of C++ Input and Output# # Streams and Buffers An input stream needs two connections, one at end. The file-end connection provides a source for the stream, and the program-end connection dumps the stre

IOS学习之table view controller、table view cell

A table view controller, like many objects, has more than one init method. There is: • initWithCoder, for view controllers that are automatically loaded from a storyboard • initWithNibName, for view controllers that you manually want to load from a n

View Controller Programming Guide for iOS---(八)---Using View Controllers in the Responder Chain

Using View Controllers in the Responder Chain 响应链中使用视图控制器 View controllers are descendants of the UIResponder class and are therefore capable of handling all sorts of events. When a view does not respond to a given event, it passes that event to its

零元学Expression Blend 4 - Chapter 17 用实例了解互动控制项「CheckBox」I

原文:零元学Expression Blend 4 - Chapter 17 用实例了解互动控制项「CheckBox」I 本章将教大家如何运用CheckBox做实作上的变化:教你如何把CheckBox变藏宝箱! ? 本章将教大家如何运用CheckBox做实作上的变化:看我怎麽把CheckBox变藏宝箱! ? 最近帮公司做了一个互动式的小游戏,运用了CheckBox的功能,就顺便介绍给大家 为了利益回避,以及日後不必要的麻烦,本章范例已经简化了很多东西,只留下与相关的图片及功能 ? 01 先简单介绍