函数介绍:
1、
// Returns interface orientation masks.
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation NS_AVAILABLE_IOS(6_0);
Returns the interface orientation to use when presenting the view controller. | |
| The system calls this method when presenting the view controller full screen. You implement this method when your view controller supports two or more orientations but the content appears best in one of those orientations. If your view controller implements this method, then when presented, its view is shown in the preferred orientation (although it can later be rotated to another supported rotation). If you do not implement this method, the system presents the view controller using the current orientation of the status bar. |
比如
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAllButUpsideDown ;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
就是说:该viewcontroller支持,除了倒置以外的三个方向,但是刚进这个界面的时候无论设备朝那个方向,都是以竖直(UIInterfaceOrientationPortrait)这个方向显示,然后你可以转到其他支持的方向。
注意:这个函数必须返回一个支持的朝向,否则会crash。