我已将我的WebView UIDelegate链接到界面构建器中的BrowserWindowController,这是我的委托,它实现了webuidelegate函数。在我的browserwindowcontroller类中,我也这样做:
类BrowserWindowController(NSWindowController):
webView = objc.IBOutlet()
def windowDidLoad(self):
self.webView.setUIDelegate_(self)
def webViewDidStartLoad_(self, webView):
print "DID LOAD START"
def webView_didFailLoadWithError_(self, webView, error):
print "ERROR"
def webViewDidFinishLoad_(self, webView):
print "DID FINISH LOAD"
def webView_shouldStartLoadWithRequest_navigationType_(self, webView, request, nav_type):
print "LOAD REQ"
调用最后四个函数(属于WebUIDelegate的一部分)。我甚至尝试过(正式协议是什么,即使这是非正式的): class BrowserWindowController(NSWindowController,WebKit.protocols.WebUIDelegate):
但这不起作用。我以相同的方式实现了WebView WebPolicyDelegate,它确实有效。为什么WebUIDelegate不起作用?我已经按照我在文档中阅读的方式将其链接起来。我错过了这个非正式协议的内容吗?
答案 0 :(得分:0)
根据Apple的文档(1),委托协议没有名为webviewDidStartLoad:的选择器。选择器是“UIWebViewDelegate”协议,但它在iOS上使用,而不是在OSX上使用。