将我的视图控制器的纵向旋转为横向和纵向模式

发布于 2024-10-14 14:43:48 字数 766 浏览 9 评论 0原文

通常,我的应用程序以纵向模式显示除报告视图之外的所有视图。仅当我处于设置视图并将设备旋转为横向模式时,才会显示报告视图。现在,当我再次将设备旋转到纵向模式时,报告视图将关闭并显示设置视图。

In report view 

> shouldAutorotateToInterfaceOrientation

return ((interfaceOrientation == UIInterfaceOrientationLandscapeRight)||( interfaceOrientation == UIInterfaceOrientationLandscapeLeft));



Here at settings view 

    shouldAutorotateToInterfaceOrientation


    if((interfaceOrientation == UIInterfaceOrientationLandscapeRight)||( interfaceOrientation == UIInterfaceOrientationLandscapeLeft))
     {  

     Report *report = [[Report alloc]initWithNibName:@"Report" bundle:[NSBundle mainBundle]]; 
     [self.navigationController pushViewController:report animated:YES];
     [report release];

     }
     return YES;
     }

Normally my application shows all views in portrait mode except report view. Report view shows only when I am on settings view and I rotate my device to landscape mode. Now when I rotate my device to portrait mode again, report view is dismissed and settings view is displayed.

In report view 

> shouldAutorotateToInterfaceOrientation

return ((interfaceOrientation == UIInterfaceOrientationLandscapeRight)||( interfaceOrientation == UIInterfaceOrientationLandscapeLeft));



Here at settings view 

    shouldAutorotateToInterfaceOrientation


    if((interfaceOrientation == UIInterfaceOrientationLandscapeRight)||( interfaceOrientation == UIInterfaceOrientationLandscapeLeft))
     {  

     Report *report = [[Report alloc]initWithNibName:@"Report" bundle:[NSBundle mainBundle]]; 
     [self.navigationController pushViewController:report animated:YES];
     [report release];

     }
     return YES;
     }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

内心荒芜 2024-10-21 14:43:48

不要在 shouldRotate... 中创建视图控制器,而是在 willRotateToInterfaceOrientation:duration: 中创建视图控制器,这是您应该响应旋转的地方。在您的 shouldAutorotateToInterfaceOrientation: 中,当您希望能够旋转到该方向时,只需返回 YES - 在您的情况下,看起来您想要旋转到所有方向,或除 PortraitUpsideDown 之外的所有方向。

willRotateToInterfaceOrientation:duration: 中,您可以根据需要推送或弹出视图控制器。

Don't create your viewcontroller in shouldRotate..., but in willRotateToInterfaceOrientation:duration:, which is where you're supposed to respond to a rotation. In your shouldAutorotateToInterfaceOrientation:, just return YES when you want to be able to rotate to that orientation- in your case, it looks like you want to either all orientations, or all orientations except PortraitUpsideDown.

In your willRotateToInterfaceOrientation:duration:, you can push your viewcontroller or pop it as needed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文