IPhone如何在旋转设备时适当调整视图大小 [英] IPhone how to properly resize view when rotating device

查看:122
本文介绍了IPhone如何在旋转设备时适当调整视图大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图调整我的视图在视图控制器,没有运气到目前为止。基本上我有一个按钮在我的视图的底部,当方向从纵向变化为横向时,按钮不再可见,因为它现在太远了。

I have been trying to resize my view inside a view Controller with no luck so far. Basically I have a button at the very bottom of my view and when the orientation changes from Portrait to Landscape the button is no longer visible, because its just too far down now.

如何调整此视图的大小,以便在方向更改时按钮仍然可见?我已经尝试设置

How can I resize this view so that when the orientation changes the button is still visible?. I have tried setting

self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

基本上每隔一个可能的组合,到目前为止没有运气。我知道我可以通过手动重新定位按钮,但有没有更好的方法来做到这一点?

and basically every other possible combination, with no luck so far. I know I can do this by manually repositioning the button, but is there a better way to do this?.

谢谢。

-Oscar

推荐答案


  1. 包含按钮的视图必须使用掩码( UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight )自动调整大小。 / li>
  2. 在包含视图 autoresizesSubviews 必须设置为YES。

  3. code> UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin 。

  1. The view containing the button must be auto-resized using your mask (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight).
  2. On the containing view autoresizesSubviews must be set to YES.
  3. The button must use UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin.

这篇关于IPhone如何在旋转设备时适当调整视图大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆