我正在使用MonoTouch构建iOS应用程序并尝试实现自定义NSUrlProtocol。
当我注册自己的协议实现时,我收到以下错误:
WebKit丢弃了一个未被捕获的异常 web视图:decidePolicyForNavigationAction:请求:帧:decisionListener: 委托: * -canInitWithRequest:仅限 为抽象类定义。限定 - [Foo.Network.NetworkServices + TestProtocol canInitWithRequest:]!
关于可能导致这种情况的任何想法?
以下是代码:
//Registering the protocol
NSUrlProtocol.RegisterClass(new Class(typeof(TestProtocol)));
public class TestProtocol : NSUrlProtocol
{
public TestProtocol ()
{
this.Client = new TestProtocolClient();
}
public override bool CanInitWithRequest (NSUrlRequest request)
{
return true;
}
}
public class TestProtocolClient : NSUrlProtocolClient
{
public override void DataLoaded (NSUrlProtocol protocol, NSData data)
{
}
public override void FailedWithError (NSUrlProtocol protocol, NSError error)
{
}
public override void ReceivedResponse (NSUrlProtocol protocol, NSUrlResponse response, NSUrlCacheStoragePolicy policy)
{
}
public override void Redirected (NSUrlProtocol protocol, NSUrlRequest redirectedToEequest, NSUrlResponse redirectResponse)
{
}
public override void CachedResponseIsValid (NSUrlProtocol protocol, NSCachedUrlResponse cachedResponse)
{
}
public override void FinishedLoading (NSUrlProtocol protocol)
{
}
public override void ReceivedAuthenticationChallenge (NSUrlProtocol protocol, NSUrlAuthenticationChallenge challenge)
{
}
public override void CancelledAuthenticationChallenge (NSUrlProtocol protocol, NSUrlAuthenticationChallenge challenge)
{
}
}