如何在iPhone中动态地将框架分配给控制器?
我知道问这个问题很愚蠢,但我是 ipad 新手,我的应用程序支持横向和纵向模式。我想将框架分配给每个控制器(标签、按钮等),以便在任何模式下控制器保持正确的对齐。请问谁能告诉我如何将框架分配给控制器?
提前致谢!
I know its silly question to ask but I am new to ipad and my app supports both mode landscape as well as portrait.I want to assign frame to every controller(labels, buttons, etc) in such a way that in whatever mode the controller remain in proper alignment.Please can anyone tell me how I can assign frame to controllers?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不要将控制器与视图混淆。视图有框架。首先,您必须通过在
shouldAutorotateToInterfaceOrientation:
方法中为所有支持的方向返回YES
来启用旋转。然后,您可以声明一个方法,为作为参数传递的方向设置视图。为每个方向的每个子视图定义框架。然后从
layoutSubviews
和/或在方向更改期间调用的任何方法(如didRotateFromInterfaceOrientation:
)调用此方法。您还可以查看
Autoresize Masks
。Don't confuse controllers to views. Views have frames. First of all you will have to enable rotation by returning
YES
for all supported orientation inshouldAutorotateToInterfaceOrientation:
method. Then you can declare a method that sets up the views for an orientation passed as argument. Define frames for each subview in each orientation.Then call this method from
layoutSubviews
and/or any of the methods called during an orientation change likedidRotateFromInterfaceOrientation:
You can also look at
Autoresize Masks
.