Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.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
Xcode 更改容器视图的属性_Xcode_Macos_Cocoa_Tabview_Nstabview - Fatal编程技术网

Xcode 更改容器视图的属性

Xcode 更改容器视图的属性,xcode,macos,cocoa,tabview,nstabview,Xcode,Macos,Cocoa,Tabview,Nstabview,我有一个包含3个选项卡的tabView,每个tabViewItems都包含一个webView。我想将每个选项卡的标题设置为每个webView呈现的HTML页面的文档。title 因此基本上,每个NSTabViewItem都有一个Webview,通过[tabViewItem setView:Webview]。 现在,在webviews的didFinishLoadForFrame委托上,我可以通过执行NSString*title=[sender StringByEvaluationJavaScrip

我有一个包含3个选项卡的tabView,每个tabViewItems都包含一个webView。我想将每个选项卡的标题设置为每个webView呈现的HTML页面的
文档。title

因此基本上,每个
NSTabViewItem
都有一个
Webview
,通过
[tabViewItem setView:Webview]。
现在,在webviews的
didFinishLoadForFrame
委托上,我可以通过执行
NSString*title=[sender StringByEvaluationJavaScriptFromString:@“document.title”]
来检索HTML页面的标题。我只能访问
sender
对象,因此我的问题是如何获取包含我的发件人的
NSTabViewItem
。换句话说,我应该在
中放置什么

[<getNSTabViewItemFromSender:sender> setLabel:title]
[设置标签:标题]

您可以通过获取任何NSView的父级

由于web视图对象被设置为选项卡的视图,因此可以找到使用特定web视图的选项卡项

[[tabView tabViewItemWithView:webView] setLabel:label];
您可以在
NSTabView
(类似这样的内容)中将其作为一个类别来实现

然后,可以为包含web视图的选项卡项设置标签

[[tabView tabViewItemWithView:webView] setLabel:label];

实际上这里它并不完全是父视图,因为:1)我做了一个
[tabViewItem setView:webView]
所以
tabViewItem
不是我的webView的superview,2)superview返回一个NSView对象,我想要的是一个NSTabViewItem。