简体   繁体   English

可可:NSOutlineView中的多行NSTextFieldCell

[英]Cocoa : Multiline NSTextFieldCell in a NSOutlineView

I am developing a Cocoa application. 我正在开发可可应用程序。

I have a NSOutlineView displaying custom cells ( cells inherits from NSTextFieldCell). 我有一个NSOutlineView显示自定义单元格(单元格继承自NSTextFieldCell)。 The problem I am facing to is that the cell text is only displayed on one line... how can I have a multiline textField ??? 我面临的问题是单元格文本仅显示在一行上...我如何拥有多行textField?

Thanks for reading ;) 谢谢阅读 ;)

  1. Configure your table column's dataCell to wrap instead of scroll with -[NSCell setWraps:] 使用-[NSCell setWraps:]将表列的dataCell配置为环绕而不是滚动
  2. Implement -[NSObject outlineView: heightOfRowByItem:] in your outline view delegate. 在大纲视图委托中实现-[NSObject outlineView:heightOfRowByItem:]。
  3. Use -[NSCell cellSizeForBounds:] to find the height of the cell for a specific width. 使用-[NSCell cellSizeForBounds:]查找特定宽度的单元格高度。 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. 对于cellSizeForBounds :,您可以传递一个真正高的矩形,它是您的列的宽度,它将返回一个较小的矩形,该矩形是使文本适合该宽度的正确高度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM