UIView autoresizingmask不适用于我 [英] UIView autoresizingmask not working for me

查看:52
本文介绍了UIView autoresizingmask不适用于我的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了我的应用程序,以便可以自动旋转.诸如tableviewcontrollers和tabbarcontrollers之类的东西会自动调整自身大小,而无需我编写任何代码.但是,当设备转为横向时,我需要Webview等来调整大小.我设置:

I have my app set up so that auto-rotate works. Things like tableviewcontrollers and tabbarcontrollers automatically resize them selves without the need for me to write any code. However I need my webview etc. to resize when the device is turned to landscape. I set:

    webView.autoresizingMask = UIViewAutoresizingFlexibleWidth;

但是当我旋转设备时,它不会调整大小.我执行不正确吗?

but when I rotate the device it does not resize. I am implementing this incorrectly?

推荐答案

我想我终于明白了.看来,NIB文件的根视图不允许您在接口构建器中为自动调整大小蒙版指定灵活的宽度和灵活的高度(至少从3.2开始).看一看.将以下代码放在您的 viewDidLoad 中似乎可以解决此问题:

I think I finally figured this out. It seems that the root view of a NIB file does not allow you to specify flexible width and flexible height for the autoresizing mask in interface builder (at least not as of 3.2). Take a look. Putting the following code in your viewDidLoad seems to fix the problem:

self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

我是在 super 调用之后完成的.

I did it after the super call.

这篇关于UIView autoresizingmask不适用于我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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