mainBundle = [NSBundle mainBundle]; 或者通过Core Foundation来获取,如果你在写一个基于C的APP的话: mainBundle = CFBundleGetMainBundle...myBundle = [NSBundle bundleWithPath:@"/Library/MyBundle.bundle"]; CFURLRef bundleURL; CFBundleRef myBundle...例如: NSBundle* myBundle = [NSBundle bundleWithIdentifier:@"com.apple.myPlugin"]; 如果要通过Core Foundation来使用
BOOL)animated{ [super viewDidAppear:animated]; [self setupWebViewController: [[NSBundle...] pathForResource:KNUserGuideURL ofType:@"html"] ]; // [self setupAXWebViewController: [[NSBundle...setupWebViewController:(NSString*)path{ NSURL *baseURL = [NSURL fileURLWithPath:[[NSBundle...154489282 1.3 核心代码 通过文件名获取path [wself setupAXWebViewController: [[NSBundle...setupAXWebViewController:(NSString*)path{ NSURL *baseURL = [NSURL fileURLWithPath:[[NSBundle
加载本地.json文件 stringWithContentsOfFile NSString *jsonPath = [[NSBundle mainBundle] pathForResource:@"sectionMdl23...加载本地.html文件 stringWithContentsOfFile NSString *path = [[NSBundle mainBundle] pathForResource:@"html/start...]; [self.webView loadHTMLString:htmlString1 baseURL:url]; initWithContentsOfFile NSString *path = [[NSBundle...#pragma mark - 处理html字符串 - (NSString *)getTheHtmlString{ //1.配置模版信息 NSString *path = [[NSBundle...//本地json - (void)initData { NSString *jsonPath = [[NSBundle mainBundle] pathForResource:@"sectionMdl23
//获取主视图的导航控制器 7 UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle...id)sender { 2 3 UIStoryboard *storybaord = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle...tap1:(id)sender { 2 UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle...sender { 8 9 UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle...tap3:(id)sender { 16 UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle
加载图片 把图片放到资源文件夹main.bundle后,再加载图片,可以参考下面的代码,这样做的额外的好处就是可以适当减小图片加载的内存占用问题: NSString * bundlePath = [[NSBundle...mainBundle].resourcePath stringByAppendingPathComponent:@"main.bundle"]; NSBundle * mainBundle = [NSBundle...相对完整代码如下,最终输出的图片尺寸在iPhone上为原始尺寸的1/3,在iPad上为原始尺寸的1/2,正是我们需要的: NSString * bundlePath = [[NSBundle mainBundle...].resourcePath stringByAppendingPathComponent:@"main.bundle"]; NSBundle * mainBundle = [NSBundle bundleWithPath...mainBundle].resourcePath stringByAppendingPathComponent: bundleName]; NSBundle * mainBundle = [NSBundle
,我们需要从动态库中去加载他们 那么怎么来获取动态库,那当然是动态获取啦 //自定义framework Mach-O Type 为 dynamic 的时候bundle可以采用这两个加载 NSBundle...* dyBundle = [NSBundle bundleWithIdentifier:@"xsk.EmbededFramework"]; NSBundle * bundle = [NSBundle...forCellReuseIdentifier:@"TableViewCell"]; 通过class来动态查询出关联的bundle 或者 通过 framework的identifier 下面是官方的解释 Returns the NSBundle...Returns the NSBundle object with which the specified class is associated....[[EmViewController alloc] initWithNibName:@"EmbededFramework.framework/EmViewController" bundle:[NSBundle
error localizedDescription]); }]; 使用AVAsset加载资源: NSURL *assetURL = [[NSBundle...break; default: break; } }]; 获得元数据 NSURL *assetURL = [[NSBundle...{ albumItem = albumMetadata[0]; } }]; 使用AVMetadataItem NSURL *assetURL = [[NSBundle
2、s.resources文件问题,加载的bundle方式 + (UIImage *)imageNamedFromiComeSDKBundle:(NSString *)name { NSBundle...@"png"]; image = [UIImage imageWithContentsOfFile:imagePath]; } return image; } + (NSBundle...*)ic_imagePickerBundle { NSBundle *bundle = [NSBundle bundleForClass:[iComeApiManager class]];...NSURL *url = [bundle URLForResource:@"iComeBundle" withExtension:@"bundle"]; bundle = [NSBundle bundleWithURL...:url]; return bundle; } 3、加载Bundle时可能会碰到not yet loaded,不知道为啥,我这直接忽略了,然后图片正常加载 NSBundle *imageBundle
mainBundle 这样当然就无法加载到图片啦,我们需要让它加载自己当前所在bundle里的图片 ,所以加载图片的代码需要进行修改 NSString *normalImgName = @"个人@2x.png"; NSBundle...*curBundle = [NSBundle bundleForClass:self.class]; // 获取当前bundle NSString *normalImgPath = [curBundle...LXFMain.bundle并不好,不可控,所以还需要改进一下: NSString *normalImgName = [NSString stringWithFormat:@"%@@2x.png", normalImg]; NSBundle...*curBundle = [NSBundle bundleForClass:self.class]; // *********** 重点 *********** // NSString *curBundleName...成功加载 三、聊聊xib Xib的加载也是如此 NSBundle *curBundle = [NSBundle bundleForClass:self.class]; LXFCenterView *centerView
Bundle加载动画 + (nonnull instancetype)animationNamed:(nonnull NSString *)animationName inBundle:(nonnull NSBundle...+ (nonnull instancetype)animationFromJSON:(nullable NSDictionary *)animationJSON inBundle:(nullable NSBundle...instancetype)animationNamed:(nonnull NSString *)animationName inBundle:(nonnull NSBundle...animationFromJSON:(nullable NSDictionary *)animationJSON inBundle:(nullable NSBundle...Nonnull)initWithJSON:(NSDictionary * _Nullable)jsonDictionary withAssetBundle:(NSBundle
CGRectMake(0, 40, self.view.frame.size.width, self.view.frame.size.height - 20)]; NSString *path = [[NSBundle...mainBundle] bundlePath]; NSURL *baseURL = [NSURL fileURLWithPath:path]; NSString * htmlPath = [[NSBundle...CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; // NSString *path = [[NSBundle...mainBundle] bundlePath]; // NSURL *baseURL = [NSURL fileURLWithPath:path]; // NSString * htmlPath = [[NSBundle
答案是工程中的资源文件在NSBundle,而NSBundle会被打包到.ipa文件上传到App Store,而用户安装App时候,会把App放置在应用目录(非沙盒目录)。...NSBundle 在用NSFileManager去读取文件的时候需要提供文件路径,但是有时候我们并不知道资源被放置在哪个目录,此时可以用到NSBundle。...NSBundle就是系统提供,用来读取这些资源的类。...NSBundle * mainBundle = [NSBundle mainBundle]; 这样我们就拿到我们的mainBundle,通过mainBundle我们可以查找对应的资源: NSString...NSString *path = [[NSBundle mainBundle] pathForResource:@"SSTestPod" ofType:@"bundle"]; NSBundle *podBundle
xib自定义控件 新建一个继承UIView的类 +(instancetype)photoViewWithPhoto:(Photo *)photo { SYLView *sylView = [[[NSBundle...pledge.text = photo.pledge; } 加载 xib方法 xib 编译之后变为 Nib 文件 第一种加载方法 //返回一个数组 NSArry *xibArray = [[NSBundle...loadNibNamed:NSStringFromClass(self) owner:nil options:nil]; 第二中加载方法 /* * 参数 NSString * 是 xib 文件名 * NSBundle...如果传入参数是 mainBundle 则可以传入 nil * */ UINib *nib = [UINib nibWithNibName: bundle:<#(NSBundle
mark下如何获取设备相关的信息 NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary]; // app名称 NSString...currentDevice] localizedModel]; NSLog(@"国际化区域名称: %@",localPhoneModel ); NSDictionary *infoDictionary = [[NSBundle
NSBundle *bundle = [NSBundle mainBundle]; NSDictionary *info = [bundle infoDictionary]; if ([info objectForKey
//设置代理 webView.delegate = self; //2.加载请求 //加载的三种方式,加载三种数据 //《1》加载url请求 // NSURL url = [[NSBundle...]; //《2》加载html(用于显示传递过来的内容,因为loadHTMLString传递的是什么,就显示什么)(这种方式加载的网页,不能回退) // NSString path = [[NSBundle...loadHTMLString:string baseURL:nil]; //《3》加载data数据(可以加载图片,word,pdf等)(这个方法加载的也不能回退) //获取路径 NSString * path = [[NSBundle
isHTML:NO]; //发送图片附件 //第一个图片名字是本地要选择发送的图片的名字, 第二个图片的名字是邮件里发送时显示的图片名字 NSString *pathImage = [[NSBundle...addAttachmentData:dataImage mimeType:@”image/jpg” fileName:@”1.jpg”]; //发送txt文本附件 NSString *pathText = [[NSBundle...addAttachmentData:dataText mimeType:@”text/txt” fileName:@”aa.txt”]; //发送doc文本附件 NSString *pathDoc = [[NSBundle...addAttachmentData:dataDoc mimeType:@”text/doc” fileName:@”MyText.doc”]; //发送pdf文档附件 NSString *pathPdf = [[NSBundle
NSString *pathString = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"h5...NSString *pathString = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"h5...NSString *pathString = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"h5
*imgView=[[UIImageView alloc] initWithFrame:CGRectMake(50, 50, 50,50)]; NSString *bundlePath = [[ NSBundle...mainBundle] pathForResource:@"Image" ofType :@"bundle"]; NSBundle *bundle = [NSBundle bundleWithPath
上代码和打印日志: /** 获取app的icon图标名称 */ - (void)getAppIconName{ NSDictionary *infoDict = [[NSBundle...UILaunchImageSize = "{320, 568}"; } ) */ } 看到了,项目AppIcon图标和启动图片信息,都可以从 [[NSBundle...打印所有信息看看: /** 打印app工程配置信息 */ - (void)printInfoDictionary{ NSDictionary *infoDict = [[NSBundle...图标名称 /** 支持iPhone和iPad, 获取app的icon图标名称 */ - (void)getAppIconName{ NSDictionary *infoDict = [[NSBundle...*/ } 4、打印所有配置信息 /** 打印app工程配置信息 */ - (void)printInfoDictionary{ NSDictionary *infoDict = [[NSBundle
领取专属 10元无门槛券
手把手带您无忧上云