zoukankan      html  css  js  c++  java
  • Bundle

    iOS开发中为了方便管理资源文件,可以使用bundle的方式来进行管理,比如kkgridview里就是把所需的图片文件全部放在一个bundle来管理的 .

    切记目前iOS中只允许使用bundle管理资源文件和国际化信息,不支持代码的打包。

    在xcode中只能够创建setting bundle,会默认创建一些配置文件,在xcode中无法直接删除,这也许不是我们需要的。

    那么如何使用最简单的方法创建一个bundle呢?

    1 创建一个文件夹

    2 将该文件夹重命名为a.bundle

    3 将a.bundle拖入到xcode中即可

    调用:

    - (UIImage *)imagesNamedFromCustomBundle:(NSString *)imgName
    
    {
        NSString *bundlePath=[[NSBundle mainBundle].resourcePath stringByAppendingPathComponent:@"sources.bundle"];
        
        NSBundle *bundle=[NSBundle bundleWithPath:bundlePath];
        
        NSString *imagePath =[[bundle resourcePath] stringByAppendingPathComponent:imgName];
        return [UIImage imageWithContentsOfFile:imagePath];
    }
  • 相关阅读:
    科技小论文
    一线架构—细化架构
    python20.04.10
    软件架构总结
    信息领域热词分析
    架构即未来阅读笔记二
    构架即未来阅读笔记一
    科技小论文之软件质量
    Pre-architecture的需求
    软件质量
  • 原文地址:https://www.cnblogs.com/sunjianfei/p/6693124.html
Copyright © 2011-2022 走看看