我正在开发一个iOS应用程序。我需要通过按钮单击来锁定或解锁方向。
我已经查看了这个链接。
我需要在单击按钮时锁定屏幕,如果再次单击则需要解锁。
我尝试使用这段代码,但没有什么用。
- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationPortrait | UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationLandscapeRight |UIInterfaceOrientationPortraitUpsideDown;
}
非常感谢您的帮助。