第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

什么是NSLayoutConstraint“UIView-Encapsulated-Layout

什么是NSLayoutConstraint“UIView-Encapsulated-Layout

鴻蒙傳說 2019-08-30 11:28:57
我UITableView在iOS 8下運行,并且我在故事板中使用來自約束的自動單元格高度。我的一個單元格包含一個UITextView,我需要它根據(jù)用戶輸入收縮和擴(kuò)展 - 點擊縮小/擴(kuò)展文本。我這樣做是通過向文本視圖添加運行時約束并更改約束上的常量以響應(yīng)用戶事件:-(void)collapse:(BOOL)collapse; {    _collapsed = collapse;    if(collapse)            [_collapsedtextHeightConstraint setConstant: kCollapsedHeight]; // 70.0        else            [_collapsedtextHeightConstraint setConstant: [self idealCellHeightToShowFullText]];    [self setNeedsUpdateConstraints];}當(dāng)我這樣做時,我將其包裝在tableView更新中并致電[tableView setNeedsUpdateConstraints]:[tableView beginUpdates];[_briefCell collapse:!_showFullBriefText];[tableView setNeedsUpdateConstraints];// I have also tried // [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationTop];// with exactly the same results.[tableView endUpdates];當(dāng)我這樣做時,我的單元格確實擴(kuò)展(并在進(jìn)行動畫時動畫)但是我得到一個約束警告:2014-07-31 13:29:51.792 OneFlatEarth[5505:730175] 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:0x7f94dced2b60 V:[UITextView:0x7f94d9b2b200'Brief text: Lorem Ipsum i...'(388)]>",    "<NSLayoutConstraint:0x7f94dced2260 V:[UITextView:0x7f94d9b2b200'Brief text: Lorem Ipsum i...']-(15)-|   (Names: '|':UITableViewCellContentView:0x7f94de5773a0 )>",388是我計算的高度,其他約束UITextView是我的Xcode / IB。最后一個困擾我 - 我猜UIView-Encapsulated-Layout-Height這是第一次渲染時單元格的計算高度 - (我將我的UITextView高度設(shè)置為> = 70.0)但是這個派生約束然后否定了更新了用戶cnstraint。更糟糕的是,雖然布局代碼表示它試圖打破我的高度限制,但它沒有 - 它繼續(xù)重新計算單元格高度,所有內(nèi)容都按照我的意愿繪制。那么,是什么NSLayoutConstraint UIView-Encapsulated-Layout-Height(我猜它是自動細(xì)胞大小的計算高度),我應(yīng)該如何強制它干凈地重新計算?
查看完整描述

3 回答

?
弒天下

TA貢獻(xiàn)1818條經(jīng)驗 獲得超8個贊

嘗試將您的優(yōu)先級降低_collapsedtextHeightConstraint到999.這樣系統(tǒng)提供的UIView-Encapsulated-Layout-Height約束始終優(yōu)先。


它取決于你的回歸  -tableView:heightForRowAtIndexPath:。確保返回正確的值和您自己的約束,生成的約束應(yīng)該相同。只有暫時需要您自己的約束的較低優(yōu)先級,以防止崩潰/擴(kuò)展動畫在飛行中時發(fā)生沖突。


查看完整回答
反對 回復(fù) 2019-08-30
?
慕標(biāo)5832272

TA貢獻(xiàn)1966條經(jīng)驗 獲得超4個贊

我有一個類似的場景:一個帶有一個行單元格的表視圖,其中有幾行UILabel對象。我正在使用iOS 8和自動布局。


當(dāng)我旋轉(zhuǎn)時,我得到了錯誤的系統(tǒng)計算行高(43.5遠(yuǎn)小于實際高度)。看起來像:


"<NSLayoutConstraint:0x7bc2b2c0 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x7bc37f30(43.5)]>"

這不僅僅是一個警告。我的表格視圖單元格的布局非常糟糕 - 所有文本都重疊在一條文本行上。


讓我感到驚訝的是,以下一行神奇地“修復(fù)”了我的問題(autolayout沒有任何抱怨,我得到了我在屏幕上的預(yù)期):


myTableView.estimatedRowHeight = 2.0; // any number but 2.0 is the smallest one that works

有或沒有這條線:


myTableView.rowHeight = UITableViewAutomaticDimension; // by itself this line only doesn't help fix my specific problem



查看完整回答
反對 回復(fù) 2019-08-30
  • 3 回答
  • 0 關(guān)注
  • 1067 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號