【发布时间】:2012-11-13 06:56:44
【问题描述】:
我在 iPhone 上开发了一个简单的游戏。整个游戏为横向模式,但计分板页面仅支持纵向模式。我已经检查了here的问题,我只发现将纵向模式转换为横向模式,但我需要相反的答案。谁能帮帮我?
【问题讨论】:
标签: iphone
我在 iPhone 上开发了一个简单的游戏。整个游戏为横向模式,但计分板页面仅支持纵向模式。我已经检查了here的问题,我只发现将纵向模式转换为横向模式,但我需要相反的答案。谁能帮帮我?
【问题讨论】:
标签: iphone
这很简单。首先,确保目标摘要中同时支持纵向和横向。那么:
在横向视图控制器中,添加以下内容:
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscape;
}
并在纵向 ViewController 中添加:
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskPortrait;
}
【讨论】:
我在 AppDelegate 中使用了这两个调用。仅在横向获取游戏中心(记分板)。
// Supported orientations: Landscape. Customize it for your own needs
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_6_0
- (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window
{
return UIInterfaceOrientationMaskAllButUpsideDown; //Getting error here? then update ur xcode to 4.5+
}
#endif
Xcode 设置:标记横向。
【讨论】: