Ale*_*der 6 iphone objective-c ios7
昨天我更新到最新的iOS版本,发现我的代码中的一个关键部分无法正常工作.
// file is @"2/3/3-bottom-cen.png"
NSString *filePath = [[NSBundle mainBundle] pathForResource:file
ofType:nil
inDirectory:@"VillageImages"];
Run Code Online (Sandbox Code Playgroud)
此代码导致filePath的nil值,它仅在iOS7上发生 - 代码在以前的版本上正常工作.我搜索并没有找到任何最近的相关问题所以我在这里问任何方向.
刚发现显然你不能再在第一个参数中包含路径信息pathForResource:ofType:inDirectory:,只需要文件名.
即iOS7的"工作"语法
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"3-bottom-cen.png"
ofType:nil
inDirectory:@"VillageImages/2/3"];
Run Code Online (Sandbox Code Playgroud)