簡體   English   中英

如何使NSTextView使用特定的NSTextStorage?

[英]How can I make a NSTextView use a specific NSTextStorage?

有沒有辦法將NSTextView的textStorage屬性設置為我自己的NSTextStorage? 您可以自定義NSTextContainer,因此可以執行以下操作:

NSTextView *myTV = [[NSTextView alloc] initWithFrame:CGFrameMake(0,0,100,100) 
                                    withTextStorage:myTextStorage];

如果沒有,是否有辦法在實例化文本視圖之后換出默認文本存儲空間? 是否需要通過子類化NSTextView來完成?

在文本存儲中設置屬性字符串。

[[myTV textStorage] setAttributedString:myTextStorage];

除了簡單地替換存儲中的字符串外,似乎還沒有辦法替換NSTextStorage對象本身。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM