HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – 集合视图上的奇怪的自动布局行为大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_607_1@我有一个autolayout的问题,控制台报告问题,我有一个单元格中的图像视图:
refreshCatalogue[31754:16177989] Unable to simultaneously satisfy consTraints.
    Probably at least one of the consTraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted consTraint or consTraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConsTraints that you don't understand,refer to the documentation for the UIView property translatesAutoresizingMaskIntoConsTraints) 
(
    "<NSLayoutConsTraint:0x7fa98103b740 V:[UIImageView:0x7fa9810375d0]-(0)-|   (Names: '|':UIView:0x7fa9810371d0 )>","<NSLayoutConsTraint:0x7fa98103b7e0 V:|-(0)-[UIImageView:0x7fa9810375d0]   (Names: '|':UIView:0x7fa9810371d0 )>","<NSLayoutConsTraint:0x7fa98103b8d0 UIImageView:0x7fa9810375d0.centerY == UIImageView:0x7fa981037490.centerY>","<NSLayoutConsTraint:0x7fa98103ba60 UIImageView:0x7fa981037490.top == UIView:0x7fa9810371d0.topMargin + 71>","<NSAutoresizingMaskLayoutConsTraint:0x7fa980d44a10 h=--& v=--& V:[UIView:0x7fa9810371d0(50)]>"
)

Will attempt to recover by breaking consTraint 
<NSLayoutConsTraint:0x7fa98103b8d0 UIImageView:0x7fa9810375d0.centerY == UIImageView:0x7fa981037490.centerY>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConsTraints to catch this in the debugger.
The methods in the UIConsTraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be Helpful.

问题是如果我这样做:

[self.collectionView reloadItemsATindexPaths:@[indexPath]];

没有什么显示甚至图像视图似乎有正确的框架,图像属性设置.
如果我重新加载整个集合视图:

[self.collectionView reloadData];

错误仍然存​​在,但图像显示.代码在这里开放,任何人都有兴趣看看:
https://github.com/Ridiculous-Innovations/RefreshCatalogue

此外,故事板中的所有限制似乎都是蓝色的.任何想法可能导致这个问题?

编辑:不用说,所有的元素,包括图像视图在正确的地方(我做了调试框架和设置随机颜色),但图像没有显示,直到刷新…有时,单元格根本不显示

解决方法

您有UIImageView的问题:0x7fa981037490.top == UIView:0x7fa9810371d0.topMargin 71和父帧为0高(所以imageview高度必须为负,但不允许),就像右键调用dequeueReusableCell方法. 对于这种情况,可能的解决方法是将嵌套视图(垂直空间 – catalogueHeaderCell – 图像视图和垂直空间 – catalogueCell – 信息视图)的最底层约束的更改优先级从1000到999.

大佬总结

以上是大佬教程为你收集整理的ios – 集合视图上的奇怪的自动布局行为全部内容,希望文章能够帮你解决ios – 集合视图上的奇怪的自动布局行为所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。