如何在不更改iPhone应用程序中的设备方向的情况下更改应用程序的方向 [英] How to change the orientation of the app without changing the device orientation in iphone app

查看:71
本文介绍了如何在不更改iPhone应用程序中的设备方向的情况下更改应用程序的方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更改应用程序的方向而不更改iphone应用程序中的设备方向. 我想以编程方式将视图从portraid模式更改为landscap模式.

I want to change the orientation of the app without changing the device orientation in iphone app. I want to change my view from portraid mode to landscap mode programmatically.

还想知道苹果商店会接受吗?

And also want to know that will this be accepted by the apple store or not ?

谢谢

现在我从其他人那里得到了如下解决方案

Now I got the solution from other that is as follow

[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];

当您在此时添加此行时,会出现一个警告,而要删除此警告,只需在实现文件中添加以下代码即可.

when you add this line at that time one warning appear and for remove this warning just add bellow code on you implementation file..

@interface UIDevice (MyPrivateNameThatAppleWouldNeverUseGoesHere)


    - (void) setOrientation:(UIInterfaceOrientation)orientation;


    @end

然后在下面的波纹管方法中,仅在需要时编写此代码.

and after that in bellow method just write this code if required..

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

    {

        return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);

    }

但是现在想知道这是否被苹果应用商店接受了吗?

But now want to know is this accepted by apple app store or not ?

谢谢

推荐答案

使用此行以编程方式更改方向...

use this line for programmatically change orientation...

[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];

并且在那时添加此行时,会出现一个警告,要删除此警告,只需在实现文件中添加以下代码..

and also when you add this line at that time one warning appear and for remove this warning just add bellow code on you implementation file..

@interface UIDevice (MyPrivateNameThatAppleWouldNeverUseGoesHere)
- (void) setOrientation:(UIInterfaceOrientation)orientation;
@end

然后在下面的波纹管方法中,仅在需要时编写此代码.

and after that in bellow method just write this code if required..

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    //    return NO;
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

希望对您有帮助.

:)

这篇关于如何在不更改iPhone应用程序中的设备方向的情况下更改应用程序的方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆