Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 如何在NSTextView中嵌入子视图?_Macos_Cocoa_Nstextview - Fatal编程技术网

Macos 如何在NSTextView中嵌入子视图?

Macos 如何在NSTextView中嵌入子视图?,macos,cocoa,nstextview,Macos,Cocoa,Nstextview,我有一个文本视图,我想在其中放置其他视图,如下所示: ===================================== = This is an editable NSTextView... = = /-------\ = = |Subview| = = \-------/ = = other text.

我有一个文本视图,我想在其中放置其他视图,如下所示:

=====================================
= This is an editable NSTextView... =
= /-------\                         =
= |Subview|                         =
= \-------/                         =
= other text.                       =
=====================================

NSTextAttachment
s,但它们似乎只适合图像。如何在文本中插入具有键盘/鼠标交互和子视图本身等功能的功能齐全的
NSView

您可能需要查看和
NSLayoutManager
类:

'NSTextContainer定义矩形区域,但您可以创建子类来定义其他形状的区域,例如圆形区域、有孔的区域或图形旁边的区域。'

“NSLayoutManager使用NSTextContainer确定在何处断开行、布局部分文本等。”

这可能也很方便