gpt4 book ai didi

ios - rac_signalForSelector fromProtocol,选择器不存在

转载 作者:行者123 更新时间:2023-11-30 14:05:55 24 4
gpt4 key购买 nike

我正在尝试使用 Reactive Cocoa 包装 WKWebViewDelegate。

class WebContainerView: UIView, WKNavigationDelegate
{
let webView:WKWebView

required init(coder aDecoder: NSCoder){
webView = WKWebView(frame: CGRect())
super.init(coder: aDecoder)
self.addSubview(webView)

let proto = WKNavigationDelegate.self
let selector:Selector = "webView(_:decidePolicyForNavigationAction:decisionHandler:)"
let signal = webView.rac_signalForSelector(selector, fromProtocol: proto).subscribeNext( { _ in
println("Test")
})
webView.navigationDelegate = self
}}

但是我在创建信号时收到此错误

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Selector webView(_:decidePolicyForNavigationAction:decisionHandler:) does not exist in <WKNavigationDelegate>'

选择器名称正是在委托(delegate)方法中调用它的输出:

NSLog(%@, "__FUNCTION__")

最佳答案

我找到了解决此错误的方法,即更改此行:

let selector:Selector = "webView(_:decidePolicyForNavigationAction:decisionHandler:)"

对此:

let selector:Selector = "webView:decidePolicyForNavigationAction:decisionHandler:"

关于ios - rac_signalForSelector fromProtocol,选择器不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32417183/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com