首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏nimomeng的自我进阶

    NSBundle官方文档

    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来使用

    2.6K20发布于 2018-09-13
  • 来自专栏iOS逆向与安全

    iOS加载本地HTML、pdf、doc、excel文件 & HTML字符串与富文本互转

    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

    2.4K30发布于 2021-07-05
  • 来自专栏陈满iOS

    iOS开发:从本地文件读取字符串:stringWithContentsOfFile&initWithContentsOfFile

    加载本地.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

    3.4K20发布于 2018-09-10
  • 来自专栏青玉伏案

    iOS开发之抽屉效果实现

    //获取主视图的导航控制器 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

    2.3K60发布于 2018-01-11
  • 来自专栏iOS122-移动混合开发研究院

    实现iOS图片等资源文件的热更新化(二):自定义的动态 imageNamed

    加载图片 把图片放到资源文件夹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

    1.4K60发布于 2018-01-02
  • 来自专栏APP自动化测试

    iOS-使用ALAssetsLibrary获取相册图片视频

    error localizedDescription]); }]; 使用AVAsset加载资源: NSURL *assetURL = [[NSBundle break; default: break; } }]; 获得元数据 NSURL *assetURL = [[NSBundle { albumItem = albumMetadata[0]; } }]; 使用AVMetadataItem NSURL *assetURL = [[NSBundle

    1.4K50发布于 2019-10-15
  • 来自专栏大话swift

    制作动态framework与静态framework的那些坑

    ,我们需要从动态库中去加载他们 那么怎么来获取动态库,那当然是动态获取啦 //自定义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

    2.5K20发布于 2020-05-08
  • 来自专栏LinXunFeng的专栏

    iOS 组件化开发(三):加载资源文件

    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

    2.2K41发布于 2018-06-29
  • 来自专栏移动端周边技术扩展

    Cocoapods生成静态库(完整)

    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

    4.4K50发布于 2018-06-14
  • 来自专栏一“技”之长

    iOS高质量的动画实现解决方案——Lottie

    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

    5K20发布于 2018-08-15
  • 来自专栏Python疯子

    UIWebview与OC交互以及加载失败

    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

    1.4K10发布于 2018-09-06
  • 来自专栏落影的专栏

    iOS本地数据存储

    答案是工程中的资源文件在NSBundle,而NSBundle会被打包到.ipa文件上传到App Store,而用户安装App时候,会把App放置在应用目录(非沙盒目录)。 NSBundle 在用NSFileManager去读取文件的时候需要提供文件路径,但是有时候我们并不知道资源被放置在哪个目录,此时可以用到NSBundleNSBundle就是系统提供,用来读取这些资源的类。 NSBundle * mainBundle = [NSBundle mainBundle]; 这样我们就拿到我们的mainBundle,通过mainBundle我们可以查找对应的资源: NSString NSString *path = [[NSBundle mainBundle] pathForResource:@"SSTestPod" ofType:@"bundle"]; NSBundle *podBundle

    3.7K20发布于 2019-07-15
  • 来自专栏ShaoYL

    自定义View

    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:<#(NSString *)#> bundle:<#(NSBundle

    93360发布于 2018-05-11
  • 来自专栏APP自动化测试

    获取设备信息

    mark下如何获取设备相关的信息 NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary]; // app名称 NSString currentDevice] localizedModel]; NSLog(@"国际化区域名称: %@",localPhoneModel ); NSDictionary *infoDictionary = [[NSBundle

    2.5K11发布于 2019-10-15
  • 来自专栏高性能分布式系统设计

    怎样判断iPhone/iPad是越狱的

    NSBundle *bundle = [NSBundle mainBundle]; NSDictionary *info = [bundle infoDictionary]; if ([info objectForKey

    1K50发布于 2018-04-13
  • 来自专栏大师级码师

    UIWebView的使用

    //设置代理 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

    67800发布于 2021-10-31
  • 来自专栏全栈程序员必看

    ios的邮箱怎么用_ios邮箱怎么添加多个账号

    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

    1.9K20编辑于 2022-11-08
  • 来自专栏全栈程序员必看

    Swift 书面 ToDo App

    Cell var str: String if (cell == nil) { let nibs:NSArray = NSBundle.mainBundle var bundle: NSBundle = NSBundle.mainBundle() var nib: UINib = UINib(nibName: "Cell", bundle: bundle , bundle nibBundleOrNil: NSBundle?) = NSBundle.mainBundle() var nib: UINib = UINib(nibName: "Cell", bundle: bundle) tableView.registerNib Cell var str: String if (cell == nil) { let nibs:NSArray = NSBundle.mainBundle

    2.3K20编辑于 2022-07-06
  • 来自专栏韦弦的偶尔分享

    WKWebView 加载 Uni-App 导出的本地 H5

    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

    1.5K30编辑于 2022-09-21
  • 来自专栏娱乐心理测试

    iOS 如何把图片资源打包成bundle文件及遇到的坑(详解)

     *imgView=[[UIImageView alloc] initWithFrame:CGRectMake(50, 50, 50,50)]; NSString *bundlePath = [[ NSBundle mainBundle] pathForResource:@"Image" ofType :@"bundle"]; NSBundle *bundle = [NSBundle bundleWithPath

    4.3K20发布于 2018-12-05
领券