hi i created a new group in my code and put the all images in that now resources\CountryFlags is the path i am doing this
嗨,我在我的代码中创建了一个新组,并将所有图像放入现在的资源\ CountryFlags是我正在做的这个路径
NSString *fileName = countryInfo.ImageUrl;
CCSprite *flag ;
NSString * fullPath = [[NSBundle mainBundle] pathForResource: [fileName stringByDeletingPathExtension]
ofType: [fileName pathExtension]
inDirectory: @"CountryFlags"];
if (fullPath)
{
UIImage *theImage = [UIImage imageWithContentsOfFile: fullPath];
if (theImage)
{
flag = [CCSprite spriteWithCGImage: [theImage CGImage] key: fileName];
flag.position = ccp(200, 265);
flag.scale = .255;
}
}
but fullpath always got nil and not getting the code so any one have any idea how to solve this
但是完整路径总是没有得到代码所以任何人都知道如何解决这个问题
1 个解决方案
#1
1
I think it's because there is no "CountryFlags" folder in your app's bundle. XCode does not copy directory structure of resources unless folders are added as folder references (blue folder icons in project navigator, not yellow).
我认为这是因为你的应用程序包中没有“CountryFlags”文件夹。除非将文件夹添加为文件夹引用(项目导航器中的蓝色文件夹图标,而不是黄色),否则XCode不会复制资源的目录结构。
#1
1
I think it's because there is no "CountryFlags" folder in your app's bundle. XCode does not copy directory structure of resources unless folders are added as folder references (blue folder icons in project navigator, not yellow).
我认为这是因为你的应用程序包中没有“CountryFlags”文件夹。除非将文件夹添加为文件夹引用(项目导航器中的蓝色文件夹图标,而不是黄色),否则XCode不会复制资源的目录结构。