将视图从横向旋转为纵向

发布于 2024-11-03 17:06:32 字数 263 浏览 0 评论 0原文

我有一个视图,其 xib 处于横向模式。在我的一个视图控制器中,我想以横向模式显示视图,并且它正在工作 f9。在按钮上单击的另一个视图控制器中,我希望该视图从底部进入纵向到顶部所以基本上我需要将横向视图转换为纵向视图。我已经通过 shouldAuto 旋转方法完成了,但它不起作用。我已附上屏幕截图,以便更容易理解问题在此处输入图像描述

横向视图将按原样出现。 请帮我解决这个问题 提前致谢!!

I ma having a view whose xib is in landscape mode.In my one view controller I want to show the view in landscape mode and it is working f9.In another view controller on a button click I want that view to come in portrait from bottom to top so basically I need to transform that landscape view to portrait view .I have done by shouldAuto rotate methodbut it does not work.i have attached the screenshot so that the question will be more understoodenter image description here

the landscape view is coming as it is .
Please help me in sort outing this problem
Thanks in advance!!

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

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

发布评论

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

评论(1

静若繁花 2024-11-10 17:06:32

在 view did load 方法中编写以下代码

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
[[self view] setBounds:CGRectMake(0, 0, 480, 320)];
[[self view] setCenter:CGPointMake(160, 240)];
[[self view] setTransform:CGAffineTransformMakeRotation(M_PI / 2)]; 

另外,在 XIB 中将视图框架设置为 480 X 320 而不是 320 X 480 。否则它将无法工作
您还可以在 XIB 中旋转视图。

write the following code in view did load method

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
[[self view] setBounds:CGRectMake(0, 0, 480, 320)];
[[self view] setCenter:CGPointMake(160, 240)];
[[self view] setTransform:CGAffineTransformMakeRotation(M_PI / 2)]; 

Also In your XIB set the view frame as 480 X 320 in place of 320 X 480 . Otherwise it will not work
You can also rotate your view in XIB.

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