我想在我的应用程序中消除横向方向,它是为 IOS 5 构建的。在 IOS 6 中,我知道这是可能的 - 但在早期版本中它似乎对我不起作用。
我在我的plist
文件中只设置了两个方向(顶部带有主页按钮的纵向和底部带有主页按钮的纵向)。无论如何,景观仍然出现在 IOS 5 中。
我还需要做些什么来消除这种情况的发生吗?
我想在我的应用程序中消除横向方向,它是为 IOS 5 构建的。在 IOS 6 中,我知道这是可能的 - 但在早期版本中它似乎对我不起作用。
我在我的plist
文件中只设置了两个方向(顶部带有主页按钮的纵向和底部带有主页按钮的纵向)。无论如何,景观仍然出现在 IOS 5 中。
我还需要做些什么来消除这种情况的发生吗?
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
// return (interfaceOrientation == UIInterfaceOrientationPortrait);
if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||interfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
return NO;
}
else
{
return YES;
}
}
将此代码写入 .m 文件以用于 ios5 方向
让我知道它是否有效....
快乐编码!!!!
这将起作用。转到情节提要取消选择您不想要的方向并在视图控制器中编写以下代码:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown || interfaceOrientation==UIInterfaceOrientationPortrait );
}