屏蔽煩人的Masonry約束警告控制臺輸出

在使用Masonry布局框架時,有時候因為使用不當(dāng)會導(dǎo)致約束沖突,會在控制臺輸出類似這樣的警告

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2019-03-12 23:11:35.844573+0800 artDesign[11723:4004040] [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. 
(
    "<MASLayoutConstraint:0x283438000 UILabel:0x102d8a3d0.height == 43.9659>",
    "<MASLayoutConstraint:0x283438360 UILabel:0x102d8a3d0.top == UITableViewCellContentView:0x102d8a1e0.top + 9>",
    "<MASLayoutConstraint:0x283435980 UILabel:0x102fbf420.height == 15>",
    "<MASLayoutConstraint:0x283435b60 UILabel:0x102fbf420.top == UILabel:0x102d8a3d0.bottom + 10>",
    "<MASLayoutConstraint:0x283435c20 UILabel:0x102fbf420.bottom == UITableViewCellContentView:0x102d8a1e0.bottom - 10>",
    "<NSLayoutConstraint:0x283336300 UITableViewCellContentView:0x102d8a1e0.height == 88>"
)

Will attempt to recover by breaking constraint 

這類輸出很煩,少的話可以設(shè)置約束優(yōu)先級來解決,多的話不想解決怎辦?
在網(wǎng)上找到了這個方法http://landcareweb.com/questions/7235/zai-xcodede-diao-shi-kong-zhi-tai-shu-chu-zhong-jin-yong-zi-dong-bu-ju-yue-shu-cuo-wu-xiao-xi

Swift 3

 UserDefaults.standard.setValue(false, forKey: "_UIConstraintBasedLayoutLogUnsatisfiable")

Objective-C

[[NSUserDefaults standardUserDefaults] setValue:@(NO) forKey:@"_UIConstraintBasedLayoutLogUnsatisfiable"];

可以設(shè)置該參數(shù)達(dá)到屏蔽的目的,不過警告能解決就解決吧。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 怎么開頭, 小時候老師在個人評語里寫“你似乎什么都愛但唯獨不愛學(xué)習(xí)”于是一直以來我什么都喜歡一點,是不是刻意的要去...
    自己上線閱讀 423評論 0 0
  • 時間久遠(yuǎn) 在一片花海前 我望著她 氤氳的玫瑰香氣里 她輕踮腳尖 如輕靈的仙女 裙帶飛揚 她的指尖撫過每朵花 她的微...
    言已盡閱讀 675評論 4 1
  • “啊,這么可怕!”聽聞,陳夢瑩驚恐不已,敢情要不是凌天出手相救,自己便去鬼門關(guān)走一遭了。 “這算什么,等下還有...
    圣天三土閱讀 940評論 0 0
  • 腦門發(fā)熱,一時沖動,或者是神經(jīng)搭錯線,我竟然辭職去開快餐店了,而且是加盟標(biāo)準(zhǔn)化的品牌店專做外賣。 該多想時沒想,該...
    林景達(dá)閱讀 1,152評論 0 0

友情鏈接更多精彩內(nèi)容