2015-11-13 94 views
0

當DTAttributedTextView的幀更改視圖內的內容(文本)未被中繼時。我有我的tableView單元格中的文本視圖,其高度是由佈局約束指定的,該值在代碼中更改。寬度隨基於單元格寬度的約束條件自動更改。DTAttributedTextView不會重新佈局

我試圖手動調用setNeedsLayoutlayoutIfNeededrelayoutTextsetNeedsDisplay。似乎沒有任何幫助。爲什麼內容佈局以這種方式鎖定?

這似乎對工作高度,但不適合寬度:

override func layoutSubviews() { 
    super.layoutSubviews() 

    comment.attributedTextContentView.layoutFrame = DTCoreTextLayoutFrame(
     frame: comment.frame, 
     layouter: comment.attributedTextContentView.layouter) 
    comment.relayoutText() 
} 
+0

現在剛剛更換DTAttributesTextView與UITextView的面前。在DTHTMLAttributedStringBuilder中使用DTUseiOS6Attributes選項時可以正常工作。 – Tapani

回答

0

它需要設置座標製圖到零調用relayoutText

comment.attributedTextContentView.layoutFrame = DTCoreTextLayoutFrame(
    frame: comment.frame, 
    layouter: comment.attributedTextContentView.layouter) 
//gets rid of cached layouter 
comment.layouter = nil 
comment.relayoutText()