我在我的項目中創建了一個新文件夾,其中複製了一個圖像(稱爲「io.jpg」)。
我也檢查了構建階段 - >複製束資源和文件在那裏。
所以我試圖讓這個圖片的路徑:從NSBundle獲取無路徑
NSBundle* bundle=[NSBundle mainBundle];
NSString* path=[bundle pathForResource: @"io" ofType: @"jpg"];
NSLog(@"%@",path);
但它打印(空),我也試過這樣:
NSBundle* bundle=[NSBundle mainBundle];
NSString* path=[bundle pathForImageResource: @"io"];
NSLog(@"%@",path);
但它仍然打印(空)。
有什麼問題?
你看過的實際建成的產品,以確保文件被正確複製? – jtbandes 2012-07-29 02:13:45
是的,該文件在應用程序目錄中。 – 2012-07-29 11:23:05
可能重複的[資源路徑不工作Xcode](http://stackoverflow.com/questions/11447010/resourcepath-not-working-xcode) – trojanfoe 2012-07-30 06:58:43