将"初始界面方向"app.plist条目设置为"横向"(左侧或右侧主页按钮)并添加(或更可能取消注释和编辑)以下视图控制器方法:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
Run Code Online (Sandbox Code Playgroud)
小智 6
Marcelo的答案是不正确的,因为UIInterfaceOrientationLandscape它不是一个有效的标识符,因此会导致构建失败.
progrmr的答案是正确的:
return interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight;
Run Code Online (Sandbox Code Playgroud)
(抱歉没有评论第一个答案,但是当我写这篇文章时我没有足够的声誉点......)
| 归档时间: |
|
| 查看次数: |
10330 次 |
| 最近记录: |