Teask Nick
Teask Nick

Reputation: 69

Can't Override UIView.Draw Method

I need to override the draw method, but I get the error message:

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

This is what I do: I 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'm trying the Xamarin's tutorial. http://developer.xamarin.com/guides/ios/application_fundamentals/graphics_animation_walkthrough/

Upvotes: 3

Views: 852

Answers (2)

miguel.de.icaza
miguel.de.icaza

Reputation: 32684

The problem is that you create a program with the Unified API (see "using CoreImage" at the top). In Unified API, we no longer use PointF, SizeF or RectangleF, as those are 32-bit structures, so they do not work on 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 once we officially release the final version of Unified, they will be switched over.

Upvotes: 4

user4328789
user4328789

Reputation: 11

You can't override different methods. The original method has no arguments. If you want to override the Draw method, you need to delete your Draw function arguments.

Upvotes: 1

Related Questions