我正在从 TableView 中呈现一个像这样的模态视图 Controller (忽略内存泄漏,只是测试..):
[self presentModalViewController:[[SignatureVC alloc] init] animated:YES];
在我的 SignatureVC 中,我实现了这个:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
我希望 SignatureVC 仅处于横向模式。但是,在呈现模态视图 Controller 之后,方向不会改变。 我究竟做错了什么?谢谢。
最佳答案
-shouldAutorotateToInterfaceOrientation:
方法不会旋转界面方向。如果设备方向旋转,它仅允许界面方向旋转。
如果模态视图在设备处于纵向时出现,则它将处于纵向。但是,一旦您旋转到 landscapeLeft,它将使用此代码保持锁定在该方向。
要强制界面旋转,您可以使用
[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeRight;
关于objective-c - 呈现强制横向的模态视图 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6560360/