且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在不更改iPhone应用程序中的设备方向的情况下更改应用程序的方向

更新时间:2021-07-12 01:47:24

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

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);
}

希望对您有帮助.

:)