將資源文件夾拖到Xcode的Supporting File上,然后如下圖設置:
獲取資源文件:
NSString *resPath= [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@“resourceName”];
if(resPath) ;
self.backgroundIV.image = [UIImage imageWithContentsOfFile:resPath stringByAppendingPathComponent:@"A.jpg"] ;
如果資源文件比較大時,建議使用外部路徑,模擬器貌似沒有沙盒,模擬器里是可以讀取指定路徑的文件的,當發布程序時,再將路徑改為資源文件路徑。
如模擬器調試時:NSString* respath = @"/resourceName";
發布時:
NSString *resPath= [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@“resourceName”];
if(resPath) ;