Forum Xamarin.Mac
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

How to use UIImage (type/namespace not found)

SFBSamosSFBSamos USMember

Hi,

Being a total beginner with Xamarin on mac, I was aiming to create a simple app that would retrieve a picture from the internet and show it in an NSImageView.

I followed the Microsoft tutorial Getting started - Hello, Mac – Walkthrough to get started and later figured out how to add the image view component. No problem here. But when I add the following code in my ViewController class:

static UIImage FromUrl(string uri)
{
    using (var url = new NSUrl(uri))
    using (var data = NSData.FromUrl(url))
                return UIImage.LoadFromData(data);
}

I get the following error message:
error CS0246: The type or namespace name 'UIImage' could not be found (are you missing a using directive or an assembly reference?)

I can't figure out what reference to add to be able to use this type ?

As far as I can tell, Visual Studio is updated, as well my macs OS (Catalina).

Thanks for your time,
Sam

Best Answer

Answers

  • SFBSamosSFBSamos USMember

    Yep, replaced with NSImage, worked! Thanks a lot.

Sign In or Register to comment.