2

I'm trying to add a splash screen to an iOS app built using Xamarin.Forms. I'm able to get the splash screen itself to display, but I'm unable to add an image to an ImageView in the storyboard editor.

I can replicate this behavior in a brand-new "Cross Platform" solution, and I'm following the instructions here. Specifically, at step 10 in the instructions, you're supposed to be able to select the image from a dropdown.

image property

If you actually click on the arrow of what only appears to be a dropdown, however, nothing actually "drops down"; instead VS opens an OpenFileDialog entitled "Add Existing Item".

file dialog

No matter what file I choose, VS only adds it to the project's Resource folder (as a BundleResource), but doesn't change the image in the storyboard at all.

I've tried adding the images to the Asset Catalog as both a Launch Image and a regular Image Set. I've tried typing either a filename or an asset set name into the editable part of the "dropdown"; no luck. I've also tried editing the storyboard XML to add an image= attribute (to the ImageView tag), again using either a filename or an asset set name, but it doesn't work, and subsequent saves from the storyboard editor actually remove the attribute. I also tried explicitly adding the entire "Assets.xcassets" folder to the project, as suggested by one of the answers here.

FWIW, the property labeled "Highlighted", directly under "Image", also has the same behavior. I'm assuming this is a VS bug of some sort; the behavior of the property is different not only from what's described in the docs, but conflicts with the appearance of the control.

Has anyone come across a workaround?

Windows 10 Pro
VS 2017 15.8.3
Xamarin 4.11.0.756
Xamarin Designer 4.14.221
Xamarin.iOS and Xamarin.Mac SDK 11.14.0.13

DelphinusC
  • 83
  • 1
  • 11

1 Answers1

2

It is bug, you can voite to this problem https://developercommunity.visualstudio.com/content/problem/319294/xamarinios-cant-select-image-asset-for-image-view.html

helsq
  • 46
  • 2
  • Figures... Is there a way to add the image programmatically? – DelphinusC Sep 11 '18 at 06:30
  • Yes, imageView.Image = UIImage.FromBundle("asset_name"); – helsq Sep 12 '18 at 07:47
  • That imageView control is on the LaunchScreen storyboard, which is loaded by the framework as it starts up. How do I get a reference to the storyboard (and hence the imageView) before it loads? And where does the code go, Main.cs? AppDelegate.cs? – DelphinusC Sep 13 '18 at 16:31
  • Unfortunately, my method is not suitable for LaunchScreen. But checking my version I created a new clean project and the image property worked. And assets and resources. In my old project does not work, whatever I do. – helsq Sep 17 '18 at 03:49
  • 3
    Experimentally, in my case, I found that the property image does not work if I add a project like net.standard to the solution. If uncheck the project reference in references, and save solution, open storyboard designer then image property will work. – helsq Sep 20 '18 at 03:35
  • I wasn't able to remove my netstandard project from the references because it is my Xamarin.Forms shared project, and VS didn't allowed me to uncheck it. Fortunately, unloading the netstandard project works too! – Morgan Touverey Quilling Nov 05 '18 at 09:59