Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在使用 QMUIEmotion 的时候,能不能只通过displayName 获取到QMUIEmotion 的image? #60

Closed
4 tasks done
boai opened this issue Feb 22, 2017 · 5 comments
Closed
4 tasks done

Comments

@boai
Copy link

boai commented Feb 22, 2017

运行环境

  • iOS 设备:iPhone / iPad / 模拟器
  • 系统版本:iOS 10.x
  • Xcode 版本:8.x
  • QMUI iOS 版本:1.x.x

具体问题描述

@interface QMUIEmotion : NSObject

/// 当前表情的标识符,可用于区分不同表情
@Property(nonatomic, copy) NSString *identifier;

/// 当前表情展示出来的名字,可用于输入框里的占位文字,例如“[委屈]”
@Property(nonatomic, copy) NSString *displayName;

/// 表情对应的图片。若表情图片存放于项目内,则建议用当前表情的identifier作为图片名
@Property(nonatomic, strong) UIImage *image;

/**

  • 快速生成一个QMUIEmotion对象,并且以identifier为图片名在当前项目里查找,作为表情的图片
  • @param identifier 表情的标识符,也会被当成图片的名字
  • @param displayName 表情展示出来的名字
    */
  • (instancetype)emotionWithIdentifier:(NSString *)identifier displayName:(NSString *)displayName;

在textView 获取到的时QMUIEmotion 的 displayName,怎么能够根据 displayName 获取到image 呢?

@EnD

问题截图

@MoLice
Copy link
Collaborator

MoLice commented Feb 22, 2017

在我们的项目中,我们通过这种方式获取 image:

+ (UIImage *)imageForEmotionWithDisplayName:(NSString *)displayName {
    for (QMUIEmotion *emotion in [QMUIQQEmotionManager emotionsForQQ]) {
        if ([displayName isEqualToString:emotion.displayName]) {
            return emotion.image;
        }
    }
    return nil;
}

@boai
Copy link
Author

boai commented Feb 22, 2017

恩,我试试看!多谢!

@boai
Copy link
Author

boai commented Feb 22, 2017

OK ,果然是内部方法,厉害!

@boai
Copy link
Author

boai commented Feb 22, 2017

忘了有一点,MLeaksFinder 检测 QMUITabBarViewController 这个类有内存泄露!不知道准确不,你们可以看看!

@MoLice
Copy link
Collaborator

MoLice commented Feb 22, 2017

好的多谢,稍后检查一下。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants