关于Masonary布局与NSAutoresizingMaskLayoutConstraint冲突问题

在项目中出现下面的警告,虽然界面上没出现错误,但是对于有强迫症的程序员来说是难以忍受的。百度后发现一句代码就解决问题了。

[LayoutConstraints] 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) 
(
    "<MASLayoutConstraint:0x1700b4760 UITextView:0x10083a800.top == UIPlaceholderTextView:0x100414690.top>",
    "<MASLayoutConstraint:0x1700b7ca0 UITextView:0x10083a800.bottom == UIPlaceholderTextView:0x100414690.bottom - 23.4859>",
    "<NSAutoresizingMaskLayoutConstraint:0x170286bd0 UIPlaceholderTextView:0x100414690.height == 0>"
)

一般情况下加入这句代码就行了:

self.translatesAutoresizingMaskIntoConstraints = NO;
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容