iOS-生成Bundle包-引入bundle-使用bundle
来源:互联网 发布:微云同步盘for mac 编辑:程序博客网 时间:2024/06/05 15:48
NSString * bundlePath = [[ NSBundle mainBundle] pathForResource: @ "MyBundle"ofType :@ "bundle"];
NSBundle *resourceBundle = [NSBundle bundleWithPath:bundlePath];
UIViewController *vc = [[UIViewController alloc] initWithNibName:@"vc_name"bundle:resourceBundle];
UIImageView *imgView=[[UIImageView alloc] initWithFrame:CGRectMake(50, 50, 50,50)];
//这里生成bundle文件的时候所有的资源都会被添加到Contents/Resources目录下
UIImage *image = [UIImage imageNamed:@"MyBundle.bundle/Contents/Resources/img_collect_success.png"];
[imgView setImage:image];
UIImageView *imgView=[[UIImageView alloc] initWithFrame:CGRectMake(50, 50, 50,50)];
//这样能获取到资源的全路径
NSString *imgPath = [bundlePath pathForResource:@"img_collect_success" ofType:@"png"];
UIImage *image_1=[UIImage imageWithContentsOfFile:imgPath];
[imgView setImage:image_1];
#define MYBUNDLE_NAME @ "MyBundle.bundle"
#define MYBUNDLE_PATH [[[NSBundle mainBundle] resourcePath] stringByAppendingPathCom
#define MYBUNDLE [NSBundle bundleWithPath: MYBUNDLE_PATH]
- iOS-生成Bundle包-引入bundle-使用bundle
- iOS-生成Bundle包-引入bundle-使用bundle
- iOS-生成Bundle包-引入bundle-使用bundle
- iOS-生成Bundle包-引入bundle-使用bundle
- iOS-生成Bundle包-引入bundle-使用bundle
- iOS-生成Bundle包-引入bundle-使用bundle
- iOS生成Bundle包--引入bundle--使用bundle
- iOS-生成Bundle包-引入bundle-使用bundle
- iOS-生成Bundle包-引入bundle-使用bundle
- iOS-生成Bundle包-引入bundle-使用bundle
- iOS-生成Bundle包-引入bundle-使用bundle
- iOS-生成Bundle包-引入bundle-使用bundle
- iOS-生成Bundle包-引入bundle-使用bundle
- iOS-生成Bundle包
- Bundle
- Bundle
- Bundle
- Bundle
- Unity中的资源加载方法
- Linux高可用性方案之Heartbeat安装
- v8 JavaScript中绑定c++对象
- 卷积神经网络
- LeetCode-28 Implement strStr() (找出字串位置)
- iOS-生成Bundle包-引入bundle-使用bundle
- 资源共享好网站
- 横竖屏切换时,禁止activity重新创建
- JSON的方法-stringify()
- [POJ2152]消防站解题报告
- new分配的内存一定在堆上么?
- 脚本自动登陆shell脚本(简洁版)
- Win7下Apahce 2.2 + php5.4的curl打开方式
- JavaScript - 轮播广告实例