[英]How can I call a method from my bindings and override in iOS?
我有這個課:
public class ExtSwitch : Switch
{
public static readonly
BindableProperty SwitchOutsideOvalColorProperty =
BindableProperty.Create(nameof(SwitchOutsideOvalColor),
typeof(Color),
typeof(ExtSwitch),
Color.Default,
propertyChanged: HandleOutsidePropertyChanged);
public Color SwitchOutsideOvalColor {
get => (Color)GetValue(SwitchOutsideOvalColorProperty);
set => SetValue(SwitchOutsideOvalColorProperty, value); }
public void HandleOutsidePropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
var a = 99;
}
}
並且我正在嘗試創建一個iOS版本,以響應HandleOutsidePropertyChanged()。 我嘗試了這個:
[assembly: ExportRenderer(typeof(ExtSwitch), typeof(ExtSwitchRenderer))]
namespace Japanese.iOS
{
class ExtSwitchRenderer : SwitchRenderer
{
public override void HandleOutsidePropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
var a = 99;
}
}
}
但是我收到一個錯誤消息,說找不到合適的方法可以覆蓋。
HandleOutsidePropertyChanged是ExtSwitch的一種方法,ExtSwitchRenderer繼承自SwitchRenderer。
代替:
public void HandleOutsidePropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
var a = 99;
}
您需要這樣做。
public void HandleOutsidePropertyChanged(BindableObject bindable, Color oldValue, Color newValue)
{
var a = 99;
}
然后,您可以覆蓋。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.