【发布时间】:2023-03-15 05:12:01
【问题描述】:
我正在开发一个 iPhone 应用程序,我必须在其中将 oreintation 更改为 Landscapeleft 和 Landscaperight。它在 iPhone 4 中工作,但在 iPhone 5 中不工作。请让我知道如何为 ios 6 做。我的代码使用如下。
谢谢。
【问题讨论】:
标签: objective-c ios ios6 landscape
我正在开发一个 iPhone 应用程序,我必须在其中将 oreintation 更改为 Landscapeleft 和 Landscaperight。它在 iPhone 4 中工作,但在 iPhone 5 中不工作。请让我知道如何为 ios 6 做。我的代码使用如下。
谢谢。
【问题讨论】:
标签: objective-c ios ios6 landscape
添加此代码
-(NSUInteger)supportedInterfaceOrientations
{
return (UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight);
}
它对我有用 希望对你有帮助!
编辑
同时添加此代码
- (BOOL)shouldAutorotate
{
return YES;
}
【讨论】:
它不像在 IOS6 中那样好用,我遇到了同样的问题。因为他们引入了新的旋转,但是运行导航控制器的旧方式(因为我的应用程序也需要支持 4.3)确实做到了非常难。
阅读我的问题和解决方案应该可以帮助到你:
【讨论】:
试试这个
-(BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
-(BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeRight;
}
【讨论】: