我有我的资源文件夹中的“hit_circle_19.png”图像“hit_circle_0.png”,但由于某种原因,此代码从未通过测试“发现”令人讨厌的是我有完全相同的功能在另一种方法工作只是在它下面。并且这些文件中有“复制包资源”为什么这不为这些图像找到正确的pathForResource?
NSMutableArray *hitCircle = [[NSMutableArray alloc]init];
for (int i = 0; i < 20; i++) {
NSString *name = [NSString stringWithFormat:@"hit_circle_%i", i];
NSString *filePath= [[NSBundle mainBundle] pathForResource:name ofType:@"png"];
if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]){
NSLog(@"file %@ was found", filePath);
} else{
NSLog(@"%@ not found", filePath);
}
}
你确定文件名吗? iOS文件系统区分大小写。 –