[英]Bundle behaviour differs inside ios simulator and actual device
At the moment I'm trying to manage a large number of images by putting them in a folder and naming the folder [something].bundle, and dragging these into XCode.目前,我正在尝试通过将它们放在一个文件夹中并命名文件夹 [something].bundle 并将它们拖到 XCode 来管理大量图像。
Weird thing right now is that, if I run this in the simulator, I can get access to these images with [UIImage imageNamed:] as if all the files are within the main bundle;现在奇怪的是,如果我在模拟器中运行它,我可以使用 [UIImage imageNamed:] 访问这些图像,就好像所有文件都在主包中一样; but running the same code on a actual device (iPad 4.3.3 in this case), imageNamed: doesn't work.但在实际设备(本例中为 iPad 4.3.3)上运行相同的代码, imageNamed: 不起作用。
Can someone explain to me why this might be?有人可以向我解释为什么会这样吗?
You cant use imageNamed: with items in a bundle.您不能将 imageNamed: 与捆绑中的项目一起使用。
You need to either to imageWithContentsOfFile: or imageWithData:您需要 imageWithContentsOfFile: 或 imageWithData:
See (iPhone) Use external image in UIImage imageNamed for similar examples.有关类似示例,请参阅(iPhone) 在 UIImage imageNamed 中使用外部图像。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.