iPhone 方向布局从单列到双列

发布于 2024-08-27 19:08:06 字数 699 浏览 12 评论 0原文

我正在尝试在 Interface Builder 中创建一个 UIView,向用户显示两个包含一些文本的框。此 UIView 应支持横向和纵向模式。

当处于纵向时,两个框应水平居中并位于彼此下方。就像下图这样: 肖像模式 http://img176.imageshack.us/img176/5899/screenshot20100403at709.png< /a>

但在横向时,它应该显示两个垂直居中且并排的框。就像下图这样: 横向模式 http://img40.imageshack.us/img40/1669/screenshot20100403at728.png< /a>

是否可以仅使用自动调整大小选项(或任何其他 IB 选项),或者我是否必须在方向更改事件上重新布局代码中的视图?我更愿意只使用 IB。

我尝试锁定顶部框的顶部和左侧边距,并锁定底部框的底部和右侧边距。但问题是,为了让它工作,我还需要在一个从纵向变为横向时缩小两个盒子,因为否则它们会重叠。

I am trying to create a UIView in Interface Builder that shows to the user two boxes containing some text. This UIView should support both landscape and portrait modes.

When in portrait orientation, the two boxes should be centered horizontally and be under each other. Like in the picture below:
Portrait Mode http://img176.imageshack.us/img176/5899/screenshot20100403at709.png

But when in landscape orientation, it should show the two boxes centered vertically and by side by side. Like in the picture below:
Landscape Mode http://img40.imageshack.us/img40/1669/screenshot20100403at728.png

Is this possible using only the autosizing options (or any other IB options), or do I have to relayout the view in code on orientation change events? I would prefer using only IB.

I tried locking the top and left margins of the top box and locking the bottom and right margins of the bottom box. But the problem is that for it to work I also need to shrink the two boxes as one changes from portrait to landscape, because otherwise they would overlap.

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

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

发布评论

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

评论(2

∞琼窗梦回ˉ 2024-09-03 19:08:06

我会制作两个视图并使用相同的模型。我发现这极大地简化了我的代码。但是,如果您坚持使用一种视图,只需将它们轮流放置即可。

I would make two views and use the same model. I find this greatly simplifies my code. However if you insist on one view, just lay them out on rotation.

空心空情空意 2024-09-03 19:08:06

我以前做过类似的事情..

我所做的是通过代码完成的..
willRotateToInterfaceOrientation:duration: 方法调用上,我将重新绘制视图的中心点..

它对我有用:)

i did something like this previously..

what i did was done by codes..
on willRotateToInterfaceOrientation:duration: method call, i will replot the center points of the view..

it works for me :)

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