iPhone SDK:主包内的子文件夹 [英] iPhone SDK: subFolders inside the main bundle

查看:122
本文介绍了iPhone SDK:主包内的子文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在当前项目中我有许多文件夹,包含子文件夹,其中包含图像:01.png,02.png。

in the current project I have a number of folders, with subfolders, and these contain images: 01.png, 02.png.

Folder1 / FolderA / f1 .png
Folder1 / FolderB / F1.png

Folder1/FolderA/f1.png Folder1/FolderB/F1.png

当我编译应用程序时,我查看了.app并注意到所有图像都放在顶级,没有子文件夹。

When I compile the app, I looked inside the the .app and noticed that all the images are placed in the top level, with no sub-folders.

在尝试加载图片时很明显这不起作用:

So clearly when trying to load the image this doesn't work:

NSString * filePath = [[ NSBundle mainBundle] pathForResource:@f1
ofType:@png
inDirectory:@Folder1 / FolderA];

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"f1" ofType:@"png" inDirectory:@"Folder1/FolderA"];

但即便如此更奇怪的是,当加载图像f1时,图像实际加载F1

But even more strangely, when loading image "f1", the image actually loads "F1"

UIImageView * imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@f1 .png]];

UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"f1.png"]];

任何人都有关于如何解决这个问题的想法?

Anyone have ideas on how to get around this problem?

有没有编译选项在应用程序包中创建文件夹?

Is there a compile option to create the folders in the app bundle?

TIA。

推荐答案

要在.app包中创建子文件夹,您应该选中为任何添加的文件夹创建文件夹引用选项,而不是默认的为任何添加的文件夹递归创建组选项
现在在XCode中,导入文件夹显示为蓝色而不是黄色。构建并继续,您应该在.app文件中看到文件夹。

To create the subfolders inside the .app bundle, you should check the option "Create folder references for any added folders" rather than the default "Recursively create groups for any added folders" Now in XCode, your imported folder appears blue rather than yellow. Build and go and you should see folders in your .app file.

这篇关于iPhone SDK:主包内的子文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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