iOS解决控制台输出的[framework] CUICatalog: Invalid asset name supplied: '(null)' 警告

有警告洁癖的人看看吧。应该对你有用

[framework] CUICatalog: Invalid asset name supplied: '(null)'
原因:项目中的图片的名称设置为nil或者@""的原因。

问题原因:按钮的工具类封装以及使用的问题
+(UIButton * )btnInit:(NSInteger)tag title:(NSString *)title bgColor:(UIColor *)color titleColor:(UIColor *)titleColor imageNamed:(NSString *)imageNamed Font:(UIFont *)font;

    // 可以看到这里把按钮的图片设置成了nil,这就是控制台报如上问题的原因
    self.coverSexVCellBtn = [HemaFunction btnInit:129 title:@"" bgColor:[UIColor clearColor] titleColor:nil imageNamed:nil Font:nil];// orangeColor
    [self.coverSexVCellBtn addTarget:self action:@selector(leftBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:self.coverSexVCellBtn];

解决办法:封装一个不用设置按钮图片的工具类即可。
+(UIButton * )btnInit:(NSInteger)tag title:(NSString *)title bgColor:(UIColor *)color titleColor:(UIColor *)titleColor Font:(UIFont *)font;

self.coverSexVCellBtn = [HemaFunction btnInit:129 title:@"" bgColor:[UIColor clearColor] titleColor:nil Font:nil];// orangeColor
    [self.coverSexVCellBtn addTarget:self action:@selector(leftBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:self.coverSexVCellBtn];
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容