【发布时间】:2014-03-03 13:43:37
【问题描述】:
我正在尝试在 Xamarin 中为范围转换设置动画,但遇到了一些问题:
public void SetXRange(float range){
CPTXYPlotSpace space = graph.DefaultPlotSpace as CPTXYPlotSpace;
CPTPlotRange xRange = new CPTPlotRange ((NSDecimal)range, (NSDecimal)range);
CPTAnimation.Animate (
NSObject.FromObject (space),
"XRange",
new CPTAnimationPeriod (space.XRange, xRange, 2f, 0f),
CPTAnimationCurve.Linear,
new CPTAnimationDelegate());
}
这会导致此处描述的错误:Failed to create an instance of the native type 'NSObject'。
但是同样的解决方案并不适用,因为如果我将代理设置为 null 我会得到另一个错误:
“已抛出System.ArgumentNullException。参数不能为空。参数名称:animationDelegate”
即使我尝试创建委托和设置,MonoTouch.ObjCRuntime.Class.ThrowOnInitFailure = false; 我也没有得到动画,我只是避免了错误。
有没有人用 Xamarin 制作了一个正常工作的 CorePlot 动画?
【问题讨论】:
-
我不会将此作为答案,因为我不知道 Core Plot 并且无法尝试我的解决方案,但我建议您使用 do- 实现
MyCPTAnimationDelegate : CPTAnimationDelegate没有任何方法,实例化那个 (myDelegate = new MyCPTAnimationDelegate()) 的实例并传递那个对象。 -
它不会抛出异常,但它什么也不做。我已经尝试过类似的实现
ICPTAnimationDelegate并且发生了同样的事情。
标签: c# xamarin.ios xamarin core-plot