Xamarin iOS Webkit:如何解析NIDActionArity1V59?

时间:2016-04-11 19:11:18

标签: ios xamarin webkit

我需要在子类中覆盖以下DecidePolicy()但是由于编译器无法解析NIDActionArity1V59而导致构建错误。 NIDActionArity1V59在哪里实施,以便我可以应用所需的using语句

using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using Foundation;
using ObjCRuntime;

namespace WebKit
{
    //
    // Summary:
    //     Delegate object for WebKit.WKNavigation objects, provides methods relating to
    //     navigation and load policies.
    [Introduced(PlatformName.MacOSX, 10, 10, PlatformArchitecture.Arch64, null)]
    [Introduced(PlatformName.iOS, 8, 0, PlatformArchitecture.None, null)]
    [Model]
    [Protocol]
    [Register("WKNavigationDelegate", false)]
    public class WKNavigationDelegate : NSObject, IWKNavigationDelegate, INativeObject, IDisposable
    {
        [...]
        //
        // Summary:
        //     Assigns an action to be taken after the specified navigationAction has been either
        //     canceled or allowed.
        [CompilerGenerated]
        [Export("webView:decidePolicyForNavigationAction:decisionHandler:")]
        public virtual void DecidePolicy(WKWebView webView, WKNavigationAction navigationAction, [BlockProxy(typeof(NIDActionArity1V59))] Action<WKNavigationActionPolicy> decisionHandler);


        [...]
    }
}

1 个答案:

答案 0 :(得分:1)

为什么需要这个属性?您可以像

一样覆盖它
public class MyNavigationDelegate : WKNavigationDelegate
{
    public override void DecidePolicy(WKWebView webView, WKNavigationAction navigationAction, Action<WKNavigationActionPolicy> decisionHandler)
    {
        // do some stuff
    }
}

据我所知,BlockProxy属性仅在内部使用。 https://developer.xamarin.com/api/type/ObjCRuntime.BlockProxyAttribute/

如果您查看documentation,您将看不到单个属性,因为它们不是函数签名的一部分。所以我想,你通过在反编译源中看得太深,让你感到困惑;)

提示 当您键入override后跟空格时,Visual Studio会为您提供正确的重载。所以你不必搜索它们。

enter image description here