【问题标题】:Supporting multiples sreens on the ipad when setting image programmatically以编程方式设置图像时支持 ipad 上的多个屏幕
【发布时间】:2013-10-16 19:39:23
【问题描述】:

我正在尝试在我的通用单点触控应用程序中支持所有可用的屏幕。

在我的一个屏幕中,我有一个全屏 UIImage 用于显示全屏图像。图像名称是 bg.png。我的屏幕只支持纵向,我通过以下命名和大小添加了一些版本的图像:

bg.png----->320x480

bg@2x.png------>640x960

bg-568h@2x.png----->640x1136

bg-Portrait.png----->768 × 1004

bg-Portrait@2x.png----->1536 × 2008

我还使用以下代码将其分配给视图的背景:

sImage .Image = UIImage .FromFile ("ProjectRes/Images/bg.png");

虽然我将图像添加到所有版本,但我不知道为什么图像在 ipda 视网膜或 ipad 甚至 iphone 5 上质量不合适。我的代码错了吗?

编辑

我将代码更改为:

splashImage .Frame = new RectangleF (0,0,this.View .Bounds .Width ,this.View .Bounds .Height );
splashImage .Image = UIImage .FromBundle  ("ProjectRes/Images/bg");

但它还没有工作。如果它们有帮助,我将这些代码添加到我在屏幕的ViewWillAppear 方法上调用它的方法中。ViewWillAppear 是它的好地方吗?

我是否为 ipad 和 iphone 5 使用了正确的命名?我从资源中的启动图像后缀复制了后缀。其他图片也一样吗?

【问题讨论】:

    标签: iphone ipad xamarin.ios xamarin


    【解决方案1】:

    FromFile()maps to UIImage 的+imageWithContentsOfFile: 方法,不支持 UIKit 的图像命名后缀模式。您应该可以改用FromBundle(),去掉“.png”后缀,自动选择正确的资源。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多