如Steven Kramer所述,在视图控制器中定义它:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
if (toInterfaceOrientation == UIInterfaceOrientationPortrait)
return YES to allow it or NO to forbid it
if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
return YES to allow it or NO to forbid it
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft)
return YES to allow it or NO to forbid it
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
return YES to allow it or NO to forbid it
return NO; // Unknown value
}
Run Code Online (Sandbox Code Playgroud)
例如,如果您只想接受横向模式,请使用
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}
Run Code Online (Sandbox Code Playgroud)
仅限肖像,请使用 return UIInterfaceOrientationIsPortrait(toInterfaceOrientation);
| 归档时间: |
|
| 查看次数: |
3358 次 |
| 最近记录: |