iPhone开发:iPhone工程资源管理,资源路径总结
2010-06-29 15:12
211 查看
以一张图片为例 fakeXcode.png
下面以3种目录结构的方式引用这张图片:
1。直接拖进工程+copy
image = [UIImage imageNamed: @"fakeXcode.png"];
NSString *path = [[NSBundle mainBundle] pathForResource:@"fakeXcode" ofType:@"png"];
image = [[UIImage alloc]initWithContentsOfFile:path];
2.把文件夹拖进工程目录,然后拖进工程,create folder references for any added folder,(蓝色文件夹res)
image = [UIImage imageNamed: @"res/fakeXcode.png"];
NSString *path = [[NSBundle mainBundle] pathForResource:@"fakeXcode.png" ofType:nil inDirectory:@"res"];
image = [[UIImage alloc]initWithContentsOfFile:path];
3.创建bundle,把资源放进bundle(白色bundle,res.bundle)
image = [UIImage imageNamed: @"es.bundle/fakeXcode.png"];
NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"res.bundle/fakeXcode.png"];
image = [[UIImage alloc]initWithContentsOfFile:path];
下面以3种目录结构的方式引用这张图片:
1。直接拖进工程+copy
image = [UIImage imageNamed: @"fakeXcode.png"];
NSString *path = [[NSBundle mainBundle] pathForResource:@"fakeXcode" ofType:@"png"];
image = [[UIImage alloc]initWithContentsOfFile:path];
2.把文件夹拖进工程目录,然后拖进工程,create folder references for any added folder,(蓝色文件夹res)
image = [UIImage imageNamed: @"res/fakeXcode.png"];
NSString *path = [[NSBundle mainBundle] pathForResource:@"fakeXcode.png" ofType:nil inDirectory:@"res"];
image = [[UIImage alloc]initWithContentsOfFile:path];
3.创建bundle,把资源放进bundle(白色bundle,res.bundle)
image = [UIImage imageNamed: @"es.bundle/fakeXcode.png"];
NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"res.bundle/fakeXcode.png"];
image = [[UIImage alloc]initWithContentsOfFile:path];
相关文章推荐
- iphone开发中获取Documents文件夹和资源文件夹路径
- 移动项目开发笔记(总结MasterPage中的资源文件引用路径)
- iphone开发返回Documents Tmp 应用程序资源文件夹路径
- 应用程序开发总结(6)--路径管理
- iPhone、iPad开发之图片资源管理
- Atitit.研发管理--提升效率--软件开发方法DSM总结o99
- rcp(插件开发)获取Plugin/Bundle中文件资源的绝对路径
- iphone开发资源汇总
- 数据库开发管理总结
- 移动平台前端开发总结(针对iphone,Android等手机)
- 关于安卓工程导出带res资源文件的jar的总结
- 工程开发实用类与方法总结(未完)
- 移动混合开发之文件管理Final之总结
- iphone开发资源汇总
- iOS开发 ☞ 图片资源路径
- ios学习--iphone开发笔记和技巧总结(原址持续更新)
- 开发中获取项目下资源绝对路径方式有
- iOS开发那些事-构建自适应iPhone和iPad工程 推荐
- 敏捷开发系列学习总结(1)——版本管理发布流程
- iPhone开发 引用图片资源的三种方式