如何获得相对路径?
我正在 Objective-c 上编程。我有 3 个文件夹,包含 3 种语言,例如 en、ru、fr,其中包含图片 1.png、2.png、3.png。如何获得图片的相对路径?我应该如何在我的项目中添加这个文件? 我有一些警告。这是因为我有同名的来源。
Warning: Multiple build commands for output file /Users/Kate/Documents/XCode_progs/MyProject/build/Debug-iphonesimulator/MyProject/1.png
Warning: Multiple build commands for output file /Users/Kate/Documents/XCode_progs/MyProject/build/Debug-iphonesimulator/MyProject/2.png
Warning: Multiple build commands for output file /Users/Kate/Documents/XCode_progs/MyProject/build/Debug-iphonesimulator/MyProject/3.png
我的代码不起作用:
CCSprite *button = [CCSprite spriteWithFile:[NSString stringWithFormat:@"%@/1.png", lang]];
I'm programming on objective-c. I have 3 folders with 3 languages such as en, ru, fr with pictures 1.png, 2.png, 3.png. How can I get relative path for my pictures? How should I add this files in my project?
I have some warnings. Its because I have the same name of sources.
Warning: Multiple build commands for output file /Users/Kate/Documents/XCode_progs/MyProject/build/Debug-iphonesimulator/MyProject/1.png
Warning: Multiple build commands for output file /Users/Kate/Documents/XCode_progs/MyProject/build/Debug-iphonesimulator/MyProject/2.png
Warning: Multiple build commands for output file /Users/Kate/Documents/XCode_progs/MyProject/build/Debug-iphonesimulator/MyProject/3.png
My code doesn't work:
CCSprite *button = [CCSprite spriteWithFile:[NSString stringWithFormat:@"%@/1.png", lang]];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将图像添加到您的项目中,您可以调用:
如果您向该资源添加本地化(png 图像)(在 XCode 4 中选择图像文件,在实用工具面板(右侧)中您可以添加不同的本地化),然后在运行时 iOS自动选择正确本地化的文件。
Add your images to your project, that you can call:
If you add localization to this resource (png image) (in XCode 4 choose image file and in Utility panel (on right hand) you can add different localizations), then in runtime iOS choose properly localized file automatically.