Objective c Obj-C,禁用/启用屏幕旋转-执行';行不通

Objective c Obj-C,禁用/启用屏幕旋转-执行';行不通,objective-c,Objective C,我试图在我的一些ViewController中禁用和启用屏幕旋转,但它不起作用,我得到一个错误“使用未声明的标识符'shouldAutorotateToInterfaceOrientation'”我使用IOS 8,我错过了什么 - (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == U

我试图在我的一些ViewController中禁用和启用屏幕旋转,但它不起作用,我得到一个错误“使用未声明的标识符'shouldAutorotateToInterfaceOrientation'”我使用IOS 8,我错过了什么

- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation {
        return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }
试试这个:

- (BOOL)shouldAutorotate {
    return NO;
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}

将应用程序设置为旋转方向,并在希望视图旋转的每个viewcontroller中,向其余视图控制器返回“是”和“否”

  • (BOOL)应该自动旋转{ 返回否; }

  • (整数)支持的接口方向{ 返回UIInterfaceOrientationMaskPortrait; }

设置应用程序方向后,它将保持方向权限,并且不能在应用程序中间更改,因此您必须在所有ViewController中单独执行额外任务