MonoTouch UIImage.FromFile不加载视网膜资产 [英] MonoTouch UIImage.FromFile not loading retina assets

查看:147
本文介绍了MonoTouch UIImage.FromFile不加载视网膜资产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用iOS7在模拟器中进行测试。我的所有资产都是视网膜,只有@ 2x名称。我对UIImage.FromFile有一种非常奇怪的行为。
请注意,模拟器iPad和模拟器iPad Retina的行为相同。

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.

基本上:


  • UIImage.FromBundle(Images / close.png),这将有效:它加载close@2x.png并将其缩小

  • UIImage .FromFile(Images / close.png),这不起作用

  • UIImage.FromFile(Images/close@2x.png),这会加载图像,但是我我不确定它会做预期的事情(即:在非视网膜设备上缩小它并在视网膜设备上正确使用它)

任何暗示?我认为iOS7自动处理这个问题。

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

推荐答案

根据Xamarin文档 - 使用图片(查看文章末尾) - 使用FromFile类似于使用FromBundle ,除了你必须传递整个文件路径,包括文件后缀。,所以这意味着如果你使用 FromFile ,你应该添加 @ 2x 后缀到最后。

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.

这篇关于MonoTouch UIImage.FromFile不加载视网膜资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆