iPhone开发viewcontroller纵向转横向不自动旋转
我有一个视图控制器正在推动另一个应该处于横向模式的 vc,但在推动时它不会自动旋转到横向模式。仍然是肖像。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
return YES;
}
return NO;
}
当弹出 vc 并返回到第一个控制器时一切都很完美,它仅以纵向模式显示。
我可以通过旋转手机/模拟器来旋转第二个 vc,然后坚持自动旋转景观。然后弹出时也完美,返回纵向模式。
那么有没有什么方法可以将界面旋转为横向。曾尝试使用
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
但没有取得巨大成功。然后状态栏在弹出时停留在横向状态。
I have a viewcontroller that's pushing another vc that should be in landscape mode but it does not autorotate to landscape when pushed ie. still in portrait.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
return YES;
}
return NO;
}
When a popping the vc and back to the first controller all is perfect, it only displays in portrait mode only.
I can get the second vc to rotate by rotating the phone/emulator and then stick to the autorotate landscape. Then also perfect when popping, returns to portrait mode.
So is there any way to maybe progamaticly rotate the interface to landscape. Have tried using
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
But to no great success. Statusbar then stuck in landscape when popping.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的
viewDidLoad
方法中使用它,它应该可以工作Use this in your
viewDidLoad
method, it should work