iphone xcode默认为横向模式

Com*_*mma 2 iphone

如何设置iphone应用程序以横向模式启动?并保持这种方式

Mar*_*tos 7

将"初始界面方向"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)

(抱歉没有评论第一个答案,但是当我写这篇文章时我没有足够的声誉点......)