iOS-生成Bundle包-引入bundle-使用bundle
Posted 墨鱼
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iOS-生成Bundle包-引入bundle-使用bundle相关的知识,希望对你有一定的参考价值。
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)];
UIImage *image = [UIImage imageNamed:@"MyBundle.bundle/img_collect_success"];
[imgView setImage:image];
UIImageView *imgView=[[UIImageView alloc] initWithFrame:CGRectMake(50, 50, 50, 50)];
NSString *imgPath= [bundlePath stringByAppendingPathComponent :@"img_collect_success.png"];
UIImage *image_1=[UIImage imageWithContentsOfFile:imgPath];
[imgView setImage:image_1];
#define MYBUNDLE_NAME @ "MyBundle.bundle"
#define MYBUNDLE_PATH [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: MYBUNDLE_NAME]
#define MYBUNDLE [NSBundle bundleWithPath: MYBUNDLE_PATH]
以上是关于iOS-生成Bundle包-引入bundle-使用bundle的主要内容,如果未能解决你的问题,请参考以下文章
Maven bundle插件无法生成正确的Export-Package
React Native:无法在 iOS 上正确运行应用程序“加载包失败(http://localhost:8081/index.bundle?”