Search code examples
imagexamarin.iosuiimagefilepathnsbundle

MonoTouch - How to specify image path of UIImage.FromFile()


I have a path problem with UIImage.FromFile() method. My solution folder has 3 projects and the main UI project has an Images folder in it. I put all my project images in this folder and I have code like this:

UIImage myImg = UIImage.FromFile("Images/someImage.png");

I have already examined this and all these topics..

I set images property of build to "content" and etc..

Can you help me:

  • step by step adding an image to a specific project folder and use it dynamically
  • how to use NSBundle and why we have to use this?

Solution

  • Generally, if you have right clicked on the file, gone to it's properties and marked it as Content then the following will work:

    UIImage myImg = UIImage.FromFile(@"Images/someImage.png");