简体   繁体   English

iPhone如何改变风景为人像?

[英]iphone how to change landscape to portrait?

I develop a simple game in iPhone. 我用iPhone开发了一个简单的游戏。 The whole game is in landscape mode, but the scoreboard page only support portrait mode. 整个游戏处于横向模式,但记分板页面仅支持纵向模式。 I have checked the questions here, I only find turn portrait into landscape mode, but I need the opposite answer. 我在这里检查了问题,我只发现将人像变成风景模式,但是我需要相反的答案。 Could anyone help me? 有人可以帮我吗?

I used these two calls in AppDelegate. 我在AppDelegate中使用了这两个调用。 Getting game center(score board) in landscape only. 仅使游戏中心(计分板)处于横向。

// 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 settings: Mark landscape. Xcode设置:标记横向。 在此处输入图片说明

It's very simple. 非常简单 First, make sure both portrait and landscape orientations are supported in the target summary. 首先,确保目标摘要中同时支持纵向和横向。 Then: 然后:

In the landscape ViewControllers, add this: 在景观ViewControllers中,添加以下内容:

-(NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskLandscape;
}

And in the portrait ViewController, add this: 然后在肖像ViewController中添加以下代码:

-(NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskPortrait;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM