开发者

Cocoa : Multiline NSTextFieldCell in a NSOutlineView

开发者 https://www.devze.com 2023-02-06 04:59 出处:网络
I am developing a Cocoa application. I have a NSOutlineView displaying custom cells ( cells inherits from NSTextFieldCell). The problem I am facing to is that the cell text is 开发者_StackOverflow中文

I am developing a Cocoa application.

I have a NSOutlineView displaying custom cells ( cells inherits from NSTextFieldCell). The problem I am facing to is that the cell text is 开发者_StackOverflow中文版only displayed on one line... how can I have a multiline textField ???

Thanks for reading ;)


  1. Configure your table column's dataCell to wrap instead of scroll with -[NSCell setWraps:]
  2. Implement -[NSObject outlineView: heightOfRowByItem:] in your outline view delegate.
  3. Use -[NSCell cellSizeForBounds:] to find the height of the cell for a specific width. For cellSizeForBounds:, you can pass a really tall rectangle that's the width of your column, and it will return a smaller rectangle that is the right height for the text to fit in that width.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号