Gre*_*reg 15 uiimageview uisplitviewcontroller ios autolayout
我遇到了自动布局的问题,我的详细信息视图在UISplitViewController.我的视图层次结构包含UIImageView带有装饰元素的视图,图像视图的内在大小似乎搞砸了其余控件的布局.
这些是我为图像视图指定的约束:
H:[UIImageView:0xc83ba90]-(NSSpace(20))-|
H:|-(NSSpace(20))-[UIImageView:0xc83ba90]
UIImageView:0xc83ba90.bottom == UITextField:0xc83d2d0.bottom
V:[UIImageView:0xc83ba90 (3)]>,
H:[UIImageView:0xc83ba90 (532)] Hug:1 CompressionResistance:750
V:[UIImageView:0xc83ba90 (2)] Hug:250 CompressionResistance:750
Run Code Online (Sandbox Code Playgroud)
我想要的行为是调整图像视图的大小以填充其超级视图,如前两个约束所述.我看到的实际行为是图像视图仅占用由其内在大小约束描述的水平空间.它似乎也在改变其所有兄弟视图的布局,就好像superview只是在与图像视图一样宽的矩形中布局视图.
我认为指定图像视图的拥抱优先级尽可能低会让其他约束覆盖它以调整图像视图的大小.我在这做错了什么?
gun*_*ngh 11
所以,我终于找到了解决方案.
解决方案是将SuperView的拥抱优先级提高到高(750或更高),并将UIImageView的压缩阻抗优先级降低到低(250或更低).这将使约束覆盖图像的内在大小.
Content Hugging Priority - The higher this priority is, the more a view resists growing larger than its intrinsic content size.
Content Compression Resistance Priority - The higher this priority is, the more a view resists shrinking smaller than its intrinsic content size.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2427 次 |
| 最近记录: |