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];
    }
  • 相关阅读:
    MVC三层架构
    JavaScript,你好!(二)
    HTML你好!
    Typora,你好!
    安装mysqlmysql-5.7.24-linux-glibc2.12-x86_64
    sizeof与strlen的区别
    printf格式化输出
    java泛型讲解
    双系统删除Linux系统
    kali破解wifi密码
  • 原文地址:https://www.cnblogs.com/sunjianfei/p/6693124.html
Copyright © 2011-2022 走看看