我正在iOS中开发应用程序。我需要通过点击按钮锁定或解锁方向。锁定/解锁iOS中的方向更改
我已选中this链接。
我需要锁定单击按钮上的屏幕,如果再次点击意味着需要解锁。
我已经尝试使用此代码,但没有用。
- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationPortrait | UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationLandscapeRight |UIInterfaceOrientationPortraitUpsideDown;
}
任何帮助表示赞赏。
我不知道苹果公司已经修复了它,但是应该在iOS 5中完成自动旋转到接口的定向工作,并且从IOS6开始完全没有用处。我最终修复了整个应用程序的方向,因为我无法再一页一页地控制它。我很乐意知道这是否已经解决。 – Paulo
@ paulo它不是不工作,从ios 6起支持使用supportedInterfaceOrientations。 – Pochi
从iOS 6开始,方向更改将在容器控制器(如导航控制器或选项卡栏控制器)上继续。您可以重写容器控制器方法来逐页控制方向更改。 [请参阅此处](http://stackoverflow.com/questions/15004271/prevent-autorotate-for-one-view-controller/15004471#15004471) –