我需要覆盖 draw 方法,但我收到错误消息:
Draw(System.Drawing.PointF)' is marked as an override but no suitable method found to override (CS0115).
这就是我所做的:我创建一个新项目,添加一个空类并尝试覆盖。
代码如下:
using System;
using UIKit;
using System.Drawing;
using CoreGraphics;
using CoreImage;
using Foundation;
using CoreAnimation;
namespace Test
{
public class Tester : UIView
{
CGPath path;
public override void Draw (PointF rect){
base.Draw ();
}
public Tester ()
{
path = new CGPath ();
}
}
}
实际上,我正在尝试 Xamarin 的教程。 http://developer.xamarin.com/guides/ios/application_fundamentals/graphics_animation_walkthrough/
最佳答案
问题是您使用统一 API 创建程序(请参阅顶部的“使用 CoreImage”)。在统一 API 中,我们不再使用 PointF、SizeF 或 RectangleF,因为它们是 32 位结构,因此它们不适用于 32/64 位模式。
在 Unified 中,您需要使用“CGRect”而不是“RectangleF”
所以要修复你的程序,你所要做的就是用“CGRect”替换“RectangleF”
教程目前反射(reflect)的是 Classic API,一旦我们正式发布 Unified 的最终版本,它们就会切换过来。
关于c# - 无法覆盖 UIView.Draw 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27315978/