Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Can';t重写UIView.Draw方法_C#_Ios_Uiview_Xamarin_Draw - Fatal编程技术网

C# Can';t重写UIView.Draw方法

C# Can';t重写UIView.Draw方法,c#,ios,uiview,xamarin,draw,C#,Ios,Uiview,Xamarin,Draw,我需要重写draw方法,但收到错误消息: Draw(System.Drawing.PointF)”标记为覆盖,但未找到合适的覆盖方法(CS0115) 这就是我要做的:我创建一个新项目,添加一个空类并尝试重写 代码如下: using System; using UIKit; using System.Drawing; using CoreGraphics; using CoreImage; using Foundation; using CoreAnimation; namespace Test

我需要重写draw方法,但收到错误消息:

Draw(System.Drawing.PointF)”标记为覆盖,但未找到合适的覆盖方法(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的教程。
您不能覆盖不同的方法。原始方法没有参数。如果要重写Draw方法,则需要删除Draw函数参数。

问题在于您使用统一API创建了一个程序(请参见顶部的“使用CoreImage”)。在统一API中,我们不再使用PointF、SizeF或RectangleF,因为它们是32位结构,所以它们不适用于32/64位模式

在Unified中,您需要使用“CGRect”而不是“RectangleF”

所以要修复你的程序,你所要做的就是用“CGRect”替换“RectangleF”


这些教程目前反映了经典的API,一旦我们正式发布了Unified的最终版本,它们将被切换。

否,因为它们使用相同的方法。如果您看到,在他们的Draw方法中,他们执行base.Draw(rect)。也许你也需要这样做。是的,我把PointF改为CGRect,它就工作了。但是现在,我有另一个问题:Tester类是我创建的一个空类。我的主要类,视图控制器类是另一个。这似乎没什么大不了的,但是我如何在我的主体类上使用Tester类,它是使用Xamarin的示例创建的?我想在屏幕上做一行…谢谢,这对我很有帮助。