简体   繁体   English

为什么UIView在iOS中重新布局?

[英]Why UIView is relayout in iOS?

My Manager UIViewController is shown in attached figure. 附图中显示了我的Manager UIViewController。 It has Draw Chart UIView and Draw Chart UIView has a small UIView inside. 它具有Draw Chart UIView和Draw Chart UIView里面有一个小的UIView。 Draw Chart UIView's size is smaller than superview. 绘制图表UIView的大小小于Superview。

Draw Chart UIView has layout constraints as shown in the second figure. 绘制图表UIView具有布局约束,如下图所示。 Small UIView has no constraints. 小UIView没有约束。 It's locations are changed where user tap on the Draw Chart UIView. 用户在“绘制图表” UIView上点击时会更改其位置。 So no constraints. 因此没有任何限制。 When I load Draw Chart UIView, it is fine and layout is same as in constraints. 当我加载Draw Chart UIView时,它很好并且布局与约束中的相同。

The problem is when I load small UIView or keyboard appeared, Draw Chart UIView is relayout and height is taller. 问题是当我加载较小的UIView或出现键盘时,“绘制图表UIView”会重新布局并且高度会更高。 So DONE button is pushed to the lower position. 因此将“完成”按钮推到较低位置。 How to prevent, even small UIView is loaded/keyboard appeared Draw Chart UIView's size and layout are not changed. 如何防止即使很小的UIView都被加载/键盘出现绘制图表UIView的大小和布局未更改。 Can it be done in auto layout and constraints? 可以在自动布局和约束条件下完成吗? I can't find where to fix it? 我找不到要解决的地方? Thanks 谢谢

在此处输入图片说明

在此处输入图片说明

尝试将主视图放在滚动视图中,将绘图图视图放在另一个滚动视图中,然后根据需要以及在键盘弹出时更改滚动视图的y位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM