Coder Social home page Coder Social logo

提点建议 about nim-uikit-ios HOT 8 CLOSED

netease-kit avatar netease-kit commented on August 23, 2024
提点建议

from nim-uikit-ios.

Comments (8)

chrisray108 avatar chrisray108 commented on August 23, 2024

第一个问题是指上层使用到了 resource.bundle 里的图片吗?如果是使用了 resource.bundle 里的图片,建议直接 使用 UIImage+NIM.h 里的扩展方法 nim_imageInKit:

二三问题我们会在以后的版本迭代中解决的,感谢您的反馈 :)

from nim-uikit-ios.

hydyy avatar hydyy commented on August 23, 2024

NSBundle * mainBundle = [NSBundle mainBundle];
NSString * resource = [mainBundle pathForResource:@"NIMKitResource"
ofType:@"bundle"];
[NIMKit sharedKit].resourceBundleName = resource;

resource是需要设置mainBundle的

emoticonBundleName
settingBundleName
这两个却不需要... 统一了岂不是很好?

from nim-uikit-ios.

chrisray108 avatar chrisray108 commented on August 23, 2024

这个是不需要上层去赋值的,直接拿来读就可以了,具体可以参考下 UIImage+NIM 里的 nim_imageInKit: 方法实现。

from nim-uikit-ios.

hydyy avatar hydyy commented on August 23, 2024

会报错哎。 我记得是哪个地方取图片的时候, 没有从mainbound里去取。。。

from nim-uikit-ios.

chrisray108 avatar chrisray108 commented on August 23, 2024

具体错误和步骤贴出来看看呢?组件里的图片都是在 resource.bundle里的呀,组件获取图片方法也全是直接去那个bundle里拿的。

from nim-uikit-ios.

hydyy avatar hydyy commented on August 23, 2024

@implementation NIMKit

  • (instancetype)init
    {
    if (self = [super init]) {
    _resourceBundleName = @"NIMKitResource.bundle";
    _emoticonBundleName = @"NIMKitEmoticon.bundle";
    _settingBundleName = @"NIMKitSettings.bundle";
    _firer = [[NIMKitNotificationFirer alloc] init];
    _provider = [[NIMKitDataProviderImpl alloc] init]; //默认使用 NIMKit 的实现

      _layoutConfig = [[NIMCellLayoutConfig alloc] init];
    

    }
    return self;
    }

UIImage (NIMKit)

  • (UIImage *)nim_imageInKit:(NSString *)imageName{
    NSString *name = [[[NIMKit sharedKit] resourceBundleName] stringByAppendingPathComponent:imageName];
    return [UIImage imageNamed:name];
    }

直接拿的图片,这个时候,不会去MainBundle里去取

========

@implementation NIMKitGlobalConfig

  • (instancetype)init{
    self = [super init];
    if (self) {
    NSString *name = [[[NIMKit sharedKit] settingBundleName] stringByAppendingPathComponent:@"NIMKitGlobalSetting.plist"];
    NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:nil];
    NSDictionary *globalSetting = [NSDictionary dictionaryWithContentsOfFile:path];

这里的时候取得是mainbundle

from nim-uikit-ios.

chrisray108 avatar chrisray108 commented on August 23, 2024

Bundle 说白了其实也就是个文件目录。
第一个取图片是从 resourceBundleName 这个目录里取的。
第二个取配置 plist 其实是从 settingBundleName 这个目录里取的。
两处的 name 变量其实都是拼接的目录名。
mainBundle 是资源根目录的意思,是可以通过 * / * 这样的方式去拿子目录里的资源的。
而 imageNamed 默认也是走资源根目录,其实跟 [NSBundle mainBundle] 是一个意思。

from nim-uikit-ios.

hydyy avatar hydyy commented on August 23, 2024

而 imageNamed 默认也是走资源根目录,其实跟 [NSBundle mainBundle] 是一个意思。
你真的试过pod引入之后,是一个意思吗?你可以测试下的。

from nim-uikit-ios.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.