Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我在我的 NSTableView 中放置一个长字符串时,文本不会完全显示:
我需要允许用户查看整个字符串(可能带有滚动或工具提示,没关系)。有什么建议么?
谢谢
如果可以有一个多行文本视图,这将是最简单的解决方案。但从你的例子来看,我猜答案是否定的。
您可以将 NSTextField 嵌入到滚动视图中。如果文本长于允许的宽度,您可以简单地显示滚动句柄。如果没有,它们将不会显示,用户甚至不会看到它是滚动视图。
对于上述两个示例,了解文本实际有多长以及文本字段是否足够长以显示整个文本将很有帮助。
你可以做[textField sizeToFit]和[textField frame].size.width检查。
[textField sizeToFit]
[textField frame].size.width