简体   繁体   English

iPad Retina图片没有显示?

[英]iPad Retina Images not showing?

In my application, I am having trouble showing iPad Retina images. 在我的应用程序中,我无法显示iPad Retina图像。 I know I have to use the @2x~ipad.png extension in order to get them to properly show and I do that. 我知道我必须使用@2x~ipad.png扩展名才能让它们正确显示并且我这样做。 My images are named according so they are all named the same besides the extension for each device. 我的图像是根据每个设备的扩展名进行命名的。 However, my images appear blurry when viewing them on an iPad 3. I know the images are the proper size and PPI but it just doesn't look clear. 但是,在iPad 3上观看时,我的图像看起来很模糊。我知道图像的尺寸和PPI都是合适的,但它看起来并不清晰。

My images are in my 'Copy Bundle Resources' too. 我的图片也在我的'Copy Bundle Resources'中。 I have tried to clean my project, and restart Xcode. 我试图清理我的项目,然后重启Xcode。 No luck. 没运气。

Also in Interace Builder in my iPad XIB, I have each image set to the -72.png image (I guess the image automatically switches to the @2x~ipad.png if it is an iPad 3 correct?) 同样在我的iPad XIB中的Interace Builder中,我将每个图像设置为-72.png图像(我想如果iPad 3正确的话,图像会自动切换到@ 2x~ipo.png吗?)

Is there any way to confirm maybe via NSLogs to see if it is loading the correct images? 有没有办法确认可能通过NSLogs,看看它是否正在加载正确的图像? Also is there anything else I should double check to ensure that the proper images are loaded. 还有什么我应该仔细检查,以确保加载正确的图像。

Uh, if you really are doing this: 呃,如果你真的这样做:

[name]-72.png and [name]@2x~ipad.png [name] -72.png和[name] @ 2x~ipad.png

thats not right. 那是不对的。

If this is a universal app, then you have 如果这是一个通用的应用程序,那么你有

  • Foo.png (or Foo~iphone.png) and Foo@2x.png (or Foo@2x~iphone.png) [NOTE: iphone not iPhone]; Foo.png(或Foo~iphone.png)和Foo@2x.png(或Foo@2x~iphone.png)[注意:iphone不是iPhone];

  • Foo~ipad.png and Foo@2x~ipad.png Foo~ipad.png和Foo@2x~ipad.png

This all working for me in my universal app. 这一切都在我的通用应用程序中为我工作。

EDIT: you can read about the naming convention in Apple's "Resource Programming Guide", page 46: 编辑:您可以在Apple的“资源编程指南”,第46页中阅读有关命名约定的内容:

The bundle- and image-loading routines automatically look for image files with the @2x string when the underlying device has a high-resolution screen. 当底层设备具有高分辨率屏幕时,捆绑和图像加载例程会自动查找具有@ 2x字符串的图像文件。 If you combine the @2x string with other modifiers, the @2x string should come before any device modifiers but after all other modifiers, such as launch orientation or URL scheme modifiers. 如果将@ 2x字符串与其他修饰符组合使用,则@ 2x字符串应位于任何设备修饰符之前,但应位于所有其他修饰符之后,例如启动方向或URL方案修饰符。 For example: 例如:

  • MyImage.png - Default version of an image resource. MyImage.png - 图像资源的默认版本。

  • MyImage@2x.png - High-resolution version of an image resource for devices with Retina displays. MyImage@2x.png - 具有Retina显示器的设备的高分辨率版图像资源。

  • MyImage~iphone.png - Version of an image for iPhone and iPod touch. MyImage~iphone.png - 适用于iPhone和iPod touch的图像版本。

  • MyImage@2x~iphone.png - High-resolution version of an image for iPhone and iPod touch devices with Retina displays. MyImage@2x~iphone.png - 带有Retina显示屏的iPhone和iPod touch设备的高分辨率图像版本。

EDIT2: So I did trip on a reference to "-72" (and -50). EDIT2:所以我参考了“-72”(和-50)。 These were used in iOS 3.1.3 and older. 这些在iOS 3.1.3及更早版本中使用。 The full explanation is found "iOS Application Programming Guide", "App Icon" section (links too fragile to use). 完整的解释是“iOS应用程序编程指南”,“应用程序图标”部分(链接太脆弱使用)。

What I am doing is setting the image names to: 我正在做的是将图像名称设置为:

  1. [name]_ipad.png , [name]_ipad@2x.png . [name]_ipad.png[name]_ipad@2x.png [iPad] [ipad公司]
  2. [name]_ipod.png , [name]_ipod@2x.png . [name]_ipod.png[name]_ipod@2x.png [iPhone] [苹果手机]

And, I added a category on UIImage , mc_imageNamed: that appends the _ipad or _ipod based on the current device. 并且,我在UIImage上添加了一个类别, mc_imageNamed:它根据当前设备附加_ipad_ipod And of course I have set the images based on their names in the XIBs. 当然,我已根据XIB中的名称设置了图像。

This method is guaranteed to work, from my experience. 根据我的经验,这种方法可以保证有效。 It would be great if someone would fix your issue, but this solution is also available. 如果有人能解决你的问题会很棒,但这个解决方案也可用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM