Image in designer with Xcode and Monotouch

2019-05-18 16:57发布

问题:

Is there a way to allow me to select and use an image for an object in the Xcode XIB designer for a MonoTouch project?

This would be quicker than for me to do it the way I am currently doing it.

Currently, I add the image I want to the Images folder within MonoDevelop. Then I open the XIB in Xcode and add my new control. I create an Outlet for it. I go back to MonoDevelop and add code such as the following:

imgLogo.Image = UIImage.FromFile("Images/logo_sm.png");

For some reason, I can't select my MonoDevelop images in Xcode designer. The image drop down selector is always empty.

Anyway I can save time and do it this way in the designer?

回答1:

Xcode only allows images in the root-level directory to be used for xibs (even though it allows you to select images outside the root, they just don't work when the app runs). As a temporary solution, we stopped making MonoDevelop export images outside of the root directory.

A few weeks ago, I finished implementing support for a "Resource" folder which you can use to contain your images and whatnot, which will be specially synced out to Xcode and placed in the root directory of the Xcode project (and the final built app) so that you can use them from within the Xcode UI designer.

The next major release of MonoDevelop will have this feature.



标签: xamarin.ios