自动调整大小在iOS11/XCode 9中不起作用 [英] Autoresizing not working in iOS11 / XCode 9

查看:95
本文介绍了自动调整大小在iOS11/XCode 9中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用XCode 9构建iOS11时,视图的Autoresizing似乎不再可靠地工作.

It appears that the Autoresizing of views is no longer reliably working when building for iOS11 with XCode 9.

几个视图的布局最终以控件在XIB中的位置为准,但是尚未发生适当的调整大小.这在iOS10中运行良好,并且可以与运行在iOS11中的旧应用程序一起使用.但是,重新构建该应用程序的位置和大小失败.

The layout of several views end up with the positioning of controls as they are in the XIB, but the appropriate resizing has not happened. This has been working fine in iOS10, and works with our old app running in iOS11. However, rebuilding the app the positioning and sizing fails.

是否发生了一些改变,从而影响了autoresizingmask的使用?

Has something changed that impacts the use of autoresizingmask?

是否可以自动将AutoResizing转换为AutoLayout and Constraints?

Is there a way to automatically convert from AutoResizing to AutoLayout and Constraints?

修改: 麻烦的控件是UINavigationBarUIToolBar.

The controls that are giving trouble are the UINavigationBar and UIToolBar.

推荐答案

此处存在相同问题.正如@John Nimis提到的,有时玩口罩似乎可以解决问题.例如,当我们同时使用顶部和底部蒙版(UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin)时,我们成功移除了顶部蒙版.

Same issue here. As mentioned by @John Nimis playing with masks sometime seems to solve the problem. For example, when we had both top and bottom masks (UIViewAutoresizingFlexibleTopMargin| UIViewAutoresizingFlexibleBottomMargin) we got success removing the Top one.

编辑 我不知道这是否是一个确定的解决方案,但是我注意到在发生问题的每个地方,框架上都有固定的原点(x或y).例如:

EDIT I don't know if this is a definitive solution, but I noticed everywhere the issue happened I had a fixed origin (x or y) on the frame. For example:

view.frame =(view1.frame.origin.x,150,宽度,高度);

view.frame=(view1.frame.origin.x, 150, width, height);

将固定值更改为相对值(例如相对于另一个view1)可以解决蒙版问题:

Changing the fixed value in a relative value (for example respect to another view1) solved the issue with masks:

view.frame =(view1.frame.origin.x,view1.frame.origin.y + view1.frame.size.height + 20,width,height);

view.frame=(view1.frame.origin.x, view1.frame.origin.y+view1.frame.size.height+20, width, height);

这篇关于自动调整大小在iOS11/XCode 9中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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