Cannot override UIView.Draw method

I need to override the draw method, but I am getting an error:

Draw (System.Drawing.PointF) 'was marked as override, but no suitable method was found to override (CS0115).

This is what I do: create a new project, add an empty class and try to override.

Here's the code:

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 ();
        }

    }
}

      

Actually I am trying the Xamarin tutorial. http://developer.xamarin.com/guides/ios/application_fundamentals/graphics_animation_walkthrough/

+3


source to share


2 answers


The problem is that you are creating a program with a unified API (see "Using CoreImage" above). In the Unified API, we no longer use PointF, SizeF or RectangleF as these are 32-bit structures, so they do not work in 32/64 bit modes.

In Unified you need to use "CGRect" instead of "RectangleF"



So, to fix your program, all you have to do is replace "RectangleF" with "CGRect"

The tutorials currently reflect the classic API, and as soon as we officially release the final version of Unified, they will switch.

+4


source


You cannot override various methods. There are no arguments in the original method. If you want to override the Draw method, you need to remove the arguments to the Draw function.



+1


source







All Articles