MonoTouch UIImage.FromFile not loading retina assets

不打扰是莪最后的温柔 提交于 2019-12-11 14:35:10

问题


I am testing in the simulator with iOS7. All my assets are retina only with the @2x name. I have a very weird behaviour with UIImage.FromFile. Please note that the behaviour is the same with simulator iPad and simulator iPad Retina.

Basically:

  • UIImage.FromBundle("Images/close.png"), this will work: it loads the close@2x.png and scales it down
  • UIImage.FromFile("Images/close.png"), this doesn't work
  • UIImage.FromFile("Images/close@2x.png"), this loads the image but i'm not sure it will do the expected things (ie: downscale it on non retina device and use it correctly on retina device)

Any hint? I thought that iOS7 was handling this automatically.


回答1:


According to the Xamarin documentation - Working with Images (look in the end of the article) - Using FromFile is similar to using FromBundle, except that you have to pass the entire file path, including file suffix., so it means that if you are using FromFile you should add @2x suffix to the end.



来源:https://stackoverflow.com/questions/23102276/monotouch-uiimage-fromfile-not-loading-retina-assets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!