rra*_*lvv 2 xamarin.android xamarin.forms
例外是:
System.MissingMethodException
Constructor on type 'MyApp.Droid.MyGridRenderer' not found
Run Code Online (Sandbox Code Playgroud)
自定义渲染器:
using System;
using Android.Content;
using Android.Graphics;
using Android.Text;
using Android.Util;
using MyApp;
using MyApp.Droid;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(Grid), typeof(MyGridRenderer))]
namespace MyApp.Droid
{
public class MyGridRenderer : ViewRenderer<Grid, Android.Views.View>
{
protected MyGridRenderer(Context context) : base(context)
{
}
}
}
Run Code Online (Sandbox Code Playgroud)
我有Visual Studio Community for Mac版本7.3.2
以防万一,这是iOS的自定义渲染器,没有任何构造函数正常工作:
using System;
using CoreGraphics;
using CoreText;
using Foundation;
using MyApp;
using MyApp.iOS;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(Grid), typeof(MyGridRenderer))]
namespace MyApp.iOS
{
public class MyGridRenderer : ViewRenderer<Grid, UIView>
{
}
}
Run Code Online (Sandbox Code Playgroud)
Android自定义渲染器的构造函数的签名在Xamarin表单的最新版本(2.5.0)中更改为要求传递上下文.
这不是iOS所需要的.
尝试将protected更改为public.
归档时间: |
|
查看次数: |
319 次 |
最近记录: |