From ea970bdae26ddc955b3e5ea754faa30f08b25f2f Mon Sep 17 00:00:00 2001
From: 285275534 <285275534@qq.com>
Date: Tue, 28 Jun 2022 23:40:31 +0800
Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E7=95=A5=E5=BE=AE=E4=BF=AE=E6=94=B9U?=
=?UTF-8?q?I=EF=BC=8C=E6=8F=90=E9=AB=98textView=E9=AB=98=E5=BA=A6=20?=
=?UTF-8?q?=E3=80=822=E3=80=81=E9=87=8D=E5=91=BD=E5=90=8DinputView?=
=?UTF-8?q?=E3=80=823=E3=80=81=E4=BF=AE=E5=A4=8D=E8=A1=A8=E6=83=85?=
=?UTF-8?q?=E9=87=8D=E5=A4=8DimageName=E9=97=AE=E9=A2=98=E3=80=824?=
=?UTF-8?q?=E3=80=81=E5=8F=91=E9=80=81=E9=80=BB=E8=BE=91=E4=BB=A3=E7=A0=81?=
=?UTF-8?q?=E7=95=A5=E5=BE=AE=E4=BF=AE=E6=94=B9=EF=BC=8C=E6=9B=B4=E7=AC=A6?=
=?UTF-8?q?=E5=90=88=E5=AE=9E=E9=99=85IM?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../project.pbxproj | 4 +-
.../Chat/ChatViewController.m | 65 ++++++++++------
.../Chat/ChatXibViewController.m | 2 +-
.../Common/CommonCustomViewController.m | 24 +++---
.../Common/CommonViewController.h | 2 +-
.../Common/CommonViewController.m | 20 ++---
.../Discuss/DiscussViewController.m | 8 +-
.../SendButton/SendButtonViewController.h | 2 +-
.../SendButton/SendButtonViewController.m | 24 +++---
.../SwiftChat/ChatSwiftViewController.swift | 75 ++++++++++++-------
QKeyboardEmotionView.podspec | 2 +-
.../Classes/QEmotionBoardView.m | 40 +++++-----
QKeyboardEmotionView/Classes/QEmotionHelper.m | 5 +-
QKeyboardEmotionView/Classes/QInputBarView.m | 15 ++--
14 files changed, 167 insertions(+), 121 deletions(-)
diff --git a/Example/QKeyboardEmotionView.xcodeproj/project.pbxproj b/Example/QKeyboardEmotionView.xcodeproj/project.pbxproj
index 07b6e5f..726f9ff 100644
--- a/Example/QKeyboardEmotionView.xcodeproj/project.pbxproj
+++ b/Example/QKeyboardEmotionView.xcodeproj/project.pbxproj
@@ -664,7 +664,7 @@
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = com.dq.qkeyboard;
PRODUCT_NAME = "$(TARGET_NAME)";
- PROVISIONING_PROFILE_SPECIFIER = "dq-deve-profile20220323";
+ PROVISIONING_PROFILE_SPECIFIER = "dq-develop-profile20220328";
SWIFT_OBJC_BRIDGING_HEADER = "QKeyboardEmotionView/QKeyboardEmotionView-Bridging-Header.h";
SWIFT_VERSION = 5.0;
WRAPPER_EXTENSION = app;
@@ -686,7 +686,7 @@
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = com.dq.qkeyboard;
PRODUCT_NAME = "$(TARGET_NAME)";
- PROVISIONING_PROFILE_SPECIFIER = "dq-deve-profile20220323";
+ PROVISIONING_PROFILE_SPECIFIER = "dq-develop-profile20220328";
SWIFT_OBJC_BRIDGING_HEADER = "QKeyboardEmotionView/QKeyboardEmotionView-Bridging-Header.h";
SWIFT_VERSION = 5.0;
WRAPPER_EXTENSION = app;
diff --git a/Example/QKeyboardEmotionView/Chat/ChatViewController.m b/Example/QKeyboardEmotionView/Chat/ChatViewController.m
index 2d11514..fcbca26 100644
--- a/Example/QKeyboardEmotionView/Chat/ChatViewController.m
+++ b/Example/QKeyboardEmotionView/Chat/ChatViewController.m
@@ -129,26 +129,60 @@ - (void)keyboardManager:(QKeyboardManager *)keyboardManager onWholeInputViewHeig
*/
- (void)sendTextMessage:(NSString *)inputText {
- [_messageArray addObject:inputText];
+ //第1步:本地创建MessageModel,每个app的MessageModel格式都不一样,我这里demo就不演示了,用string代替
+
+ //第2步:添加到array中 + reload和滚到底部
+ [self insertAndScrollToBottom:inputText needClearInputText:YES];
+
+ //第3步,发送给服务器,我这里demo就不演示了
+// [self updateToRemote: inputText];
+}
+
+#pragma mark - Private
+
+//添加到array中 + reload和滚到底部。 needClearInputText: 是否需要清空文本框输入的内容
+- (void)insertAndScrollToBottom:(NSString *)contentModel needClearInputText:(BOOL)needClearInputText {
+
+ //添加到array中
+ [self.messageArray addObject:contentModel];
- //请不要用inputTextView.text = nil来清空文本,具体原因看方法注释
//@return 0:当前inputText只有一行;非0:动画时长
- NSTimeInterval animationDuration = [self.inputView clearInputTextBySend];
+ NSTimeInterval animationDuration = needClearInputText ? [self.inputBarView clearInputTextBySend] : 0;
+
+ //reloadData并滚到底部
+ [self reloadDataAndScrollToBottomAnimated:YES animationDelay:animationDuration];
+}
- if (animationDuration == 0){
+//reloadData并滚到底部
+- (void)reloadDataAndScrollToBottomAnimated:(BOOL)animated animationDelay:(NSTimeInterval)animationDelay {
+
+ BOOL resultAnimated = animated;
+ if (@available(iOS 13.0, *)) {
+ // ios 13、15都是ok的
+ } else {
+ //在ios12中,滚到底部再animal总是会出现最后一个Cell滚动异常,所以我干脆禁止了ios12的动画
+ resultAnimated = NO;
+ }
+
+ if (animationDelay == 0){
//如果textView的文本只有一行,那么清空输入框的时候,不会走onWholeInputViewHeightDidChange回调,也不会重新设置tableView的contentInset。所以就无需延时reloadData
- [self reloadDataAndScrollToBottomAnimated:YES];
+
+ [self.tableView reloadData];
+
+ [self scrollToBottomAnimated:resultAnimated];
} else {
//textView的文本大于一行,那么清空输入框的时候,会重设tableView的contentInset(并且我还是在0.2秒的动画里重设的),如果这时候reloadData,在低性能设备上会出现tableView来回上下移动的问题
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(animationDuration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(animationDelay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [self reloadDataAndScrollToBottomAnimated:YES];
+ [self.tableView reloadData];
+
+ [self scrollToBottomAnimated:resultAnimated];
});
}
+
}
-#pragma mark - Private
//滚到底部
- (void)scrollToBottomAnimated:(BOOL)animated {
NSInteger rows = [self.tableView numberOfRowsInSection:0];
@@ -157,21 +191,6 @@ - (void)scrollToBottomAnimated:(BOOL)animated {
}
}
-//reloadData并滚到底部
-- (void)reloadDataAndScrollToBottomAnimated:(BOOL)animated {
-
- [self.tableView reloadData];
-
- BOOL resultAnimated = animated;
- if (@available(iOS 13.0, *)) {
- } else {
- //在ios12中,滚到底部再animal总是会出现最后一个Cell滚动异常,所以我干脆禁止了ios12的动画
- resultAnimated = NO;
- }
- // ios 13、15都是ok的
- [self scrollToBottomAnimated:resultAnimated];
-}
-
- (BOOL)alreadyAtBottom {
if (((NSInteger)self.tableView.contentOffset.y) == ((NSInteger)self.tableView.contentSize.height + self.scrollviewContentInset.bottom - CGRectGetHeight(self.tableView.bounds))) {
return YES;
diff --git a/Example/QKeyboardEmotionView/Chat/ChatXibViewController.m b/Example/QKeyboardEmotionView/Chat/ChatXibViewController.m
index f91dc83..932df62 100644
--- a/Example/QKeyboardEmotionView/Chat/ChatXibViewController.m
+++ b/Example/QKeyboardEmotionView/Chat/ChatXibViewController.m
@@ -42,7 +42,7 @@ -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *
NSString *str = [NSString stringWithFormat:@"%f😄[微笑][呲牙]翁绕所😄多付所多啊打发斯蒂芬[再见][微笑2]的打法撒😄旦法[微笑毒贩夫妇][大小][捂👨🏻❤️脸][微笑]阿斯顿发斯👨🏻❤️n蒂芬[微笑]http://连哭都是打开分类[微笑]哭都\n是打开分类到😄到哭都是打开分类哭都是
✔️😄打开分类[旺柴][社会社会][6👨🏻❤️66][]是打发斯FFF的蒂芬[阿萨大师👨🏻❤️傅恩我\n若翁绕%f😄[微笑][呲牙]翁绕所😄多付所多啊打发斯蒂芬[再见][微笑2]的打法撒😄旦法[微笑毒贩夫妇][大小][捂👨🏻❤️脸][微笑]阿斯顿发斯👨🏻❤️n蒂芬[微笑]http://连哭都是打开分类[微笑]哭都\n是打开分类到😄到哭都是打开分类哭都是✔️😄打开分类[旺柴][社会社会][6👨🏻❤️66][]是打发斯FFF的蒂芬[阿萨大师👨🏻❤️傅恩我\n若翁绕[Emm][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑👨🏻❤️][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][Emm][Emm][憨笑]所👨🏻❤️多\n付所多啊😄打发斯蒂芬对的[立刻就阿杀了的减肥;垃圾收代理费即时看到发文日唉短FFF发水立方;as;的李开复;了as人][jjiidi]asdfjksajdlfk 大是大非 答[微笑]复阿斯蒂芬 FFF 阿士大夫的是👨🏻❤️n垃圾收代理费。👨🏻❤️的减肥;垃圾收代理费即[偷看]时看到发文日唉短发,的减肥;垃圾收代理费即时看到发文日唉短发。的减肥;垃圾收代理费即时看到发文日唉短发[吃鸭][汪星人]🐶[沙发斯蒂芬][大笑][]]]][[[[[]as!@#!@¥#%¥#……¥%&%……&[偷笑]【】[👋🏻][你好][再见][Emm][Emm][Emm][Emm][Emm][Emm][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][Emm][Emm][憨笑][大笑][大笑]隊_(:з」∠)_👩🏻👨🏻[Emm][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑👨🏻❤️][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][Emm][Emm][憨笑]所👨🏻❤️多\n付所多啊😄打发斯蒂芬对的[立刻就阿杀了的减肥;垃圾收代理费即时看到发文日唉短FFF发水立方;as;的李开复;了as人][jjiidi]asdfjksajdlfk 大是大非 答[微笑]复阿斯蒂芬 FFF 阿士大夫的是👨🏻❤️n垃圾收代理费。👨🏻❤️的减肥;垃圾收代理费即[偷看]时看到发文日唉短发,的减肥;垃圾收代理费即时看到发文日唉短发。的减肥;垃圾收代理费即时看到发文日唉短发[吃鸭][汪星人]🐶[沙发斯蒂芬][大笑][]]]][[[[[]][Emm][Emm][Emm][Emm][Emm][Emm][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][Emm][Emm][憨笑][大笑][大笑]隊_(:з」∠)_👩🏻👨🏻[Emm][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑👨🏻❤️][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][Emm][Emm][憨笑]所👨🏻❤️多\n付所多啊😄打发斯蒂芬对的[立刻就阿杀了的减肥;垃圾收代理费即时看到发文日唉短FFF发水立方;as;的李开复;了as人][jjiidi]asdfjksajdlfk 大是大非 答[微笑]复阿斯蒂芬 FFF 阿士大夫的是👨🏻❤️n垃圾收代理费。👨🏻❤️的减肥;垃圾收代理费即[偷看]时看到发文日唉短发,的减肥;垃圾收代理费即时看到发文日唉短发。的减肥;垃圾收代理费即时看到发文日唉短发[吃鸭][汪星人]🐶[沙发斯蒂芬][大笑][]]]][[[[[]as!@#!@¥#%¥#……¥%&%……&[偷笑]【】[👋🏻][你好][再见][Emm][Emm][Emm][Emm][Emm][Emm][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][Emm][Emm][憨笑][大笑][大笑]隊_(:з」∠)_👩🏻👨🏻❤️[Emm][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑👨🏻❤️][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][Emm][Emm][憨笑]所👨🏻❤️多\n付所多啊😄打发斯蒂芬对的[立刻就阿杀了的减肥;垃圾收代理费即时看到发文日唉短FFF发水立方;as;的李开复;了as人][jjiidi]asdfjksajdlfk 大是大非 答[微笑]复阿斯蒂芬 FFF 阿士大夫的是👨🏻❤️n垃圾收代理费。👨🏻❤️的减肥;垃圾收代理费即[偷看]时看到发文日唉短发,的减肥;垃圾收代理费即时看到发文日唉短发。的减肥;垃圾收代理费即时看到发文日唉短发[吃鸭][汪星人]🐶[沙发斯蒂芬][大笑][]]]][[[[[]as!@#!@¥#%¥#……¥%&%……&[偷笑]【】[👋🏻][你好][再见][Emm][Emm][Emm][Emm][Emm][Emm][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][憨笑][Emm][Emm][憨笑][大笑][大笑]隊_(:з」∠)_👩🏻👨🏻❤️❤️[偷看][偷看]", [[NSDate date] timeIntervalSince1970],[[NSDate date] timeIntervalSince1970]];
NSLog(@"1");
- //1次遍历,只是setAttributedString 不转表情: 内存占24.2,0.0005s; 转表情0.006;转译表情 = 0.
+ //1次遍历,只是setAttributedString 不转表情: 内存占24.2,0.0005s; 转表情0.006;
for (int i = 0; i < 1; i++){
str = [NSString stringWithFormat:@"%@%d",str,i];
label.attributedText = [[QEmotionHelper sharedEmotionHelper] attributedStringByText:str font:label.font];
diff --git a/Example/QKeyboardEmotionView/Common/CommonCustomViewController.m b/Example/QKeyboardEmotionView/Common/CommonCustomViewController.m
index bdc8d91..28bfe1e 100644
--- a/Example/QKeyboardEmotionView/Common/CommonCustomViewController.m
+++ b/Example/QKeyboardEmotionView/Common/CommonCustomViewController.m
@@ -20,7 +20,7 @@ @interface CommonCustomViewController () Bool {
if CGFloat((Int(tableView.contentOffset.y))) == (CGFloat(Int(tableView.contentSize.height)) + scrollviewContentInset().bottom - tableView.bounds.height) {
return true
diff --git a/QKeyboardEmotionView.podspec b/QKeyboardEmotionView.podspec
index ac3aafe..b1893f3 100644
--- a/QKeyboardEmotionView.podspec
+++ b/QKeyboardEmotionView.podspec
@@ -8,7 +8,7 @@
Pod::Spec.new do |s|
s.name = 'QKeyboardEmotionView'
- s.version = '2.0'
+ s.version = '2.1'
s.summary = 'Emotion-Keyboard-Audio-Chat InputBarView'
# This description is used to generate tags and improve search results.
diff --git a/QKeyboardEmotionView/Classes/QEmotionBoardView.m b/QKeyboardEmotionView/Classes/QEmotionBoardView.m
index fab2c11..745c304 100644
--- a/QKeyboardEmotionView/Classes/QEmotionBoardView.m
+++ b/QKeyboardEmotionView/Classes/QEmotionBoardView.m
@@ -1,5 +1,5 @@
//
-// QMUIEmotionView.m
+// QEmotionView.m
// qmui
//
// Created by QMUI Team on 16/9/6.
@@ -9,19 +9,19 @@
#import "QEmotionBoardView.h"
-@class QMUIEmotionPageView;
+@class UIEmotionPageView;
-@protocol QMUIEmotionPageViewDelegate
+@protocol UIEmotionPageViewDelegate
@optional
-- (void)emotionPageView:(QMUIEmotionPageView *)emotionPageView didSelectEmotion:(QEmotion *)emotion atIndex:(NSInteger)index;
-- (void)emotionPageViewDidLayoutEmotions:(QMUIEmotionPageView *)emotionPageView;
+- (void)emotionPageView:(UIEmotionPageView *)emotionPageView didSelectEmotion:(QEmotion *)emotion atIndex:(NSInteger)index;
+- (void)emotionPageViewDidLayoutEmotions:(UIEmotionPageView *)emotionPageView;
@end
/// 表情面板每一页的cell,在drawRect里将所有表情绘制上去,同时自带一个末尾的删除按钮
-@interface QMUIEmotionPageView : UIView
+@interface UIEmotionPageView : UIView
-@property(nonatomic, weak) QEmotionBoardView *delegate;
+@property(nonatomic, weak) QEmotionBoardView *delegate;
/// 表情被点击时盖在表情上方用于表示选中的遮罩
@property(nonatomic, strong) UIView *emotionSelectedBackgroundView;
@@ -68,7 +68,7 @@ @interface QMUIEmotionPageView : UIView
@end
-@implementation QMUIEmotionPageView
+@implementation UIEmotionPageView
//发送按钮,删除按钮的宽高
const int UISendButtonWidth = 52;
@@ -225,15 +225,15 @@ - (void)setDeleteButtonOffset:(CGPoint)deleteButtonOffset {
@end
-@interface QMUIEmotionVerticalScrollView : UIScrollView
-@property(nonatomic, strong) QMUIEmotionPageView *pageView;
+@interface UIEmotionVerticalScrollView : UIScrollView
+@property(nonatomic, strong) UIEmotionPageView *pageView;
@end
-@implementation QMUIEmotionVerticalScrollView
+@implementation UIEmotionVerticalScrollView
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
- _pageView = [[QMUIEmotionPageView alloc] init];
+ _pageView = [[UIEmotionPageView alloc] init];
self.pageView.deleteButton.hidden = YES;
[self addSubview:self.pageView];
}
@@ -246,7 +246,7 @@ - (void)setEmotions:(NSArray *)emotions
emotionVerticalSpacing:(CGFloat)emotionVerticalSpacing
emotionSelectedBackgroundExtension:(UIEdgeInsets)emotionSelectedBackgroundExtension
paddingInPage:(UIEdgeInsets)paddingInPage {
- QMUIEmotionPageView *pageView = self.pageView;
+ UIEmotionPageView *pageView = self.pageView;
pageView.emotions = emotions;
pageView.padding = paddingInPage;
CGSize contentSize = CGSizeMake(self.bounds.size.width - [self edgeInsetsGetHorizontalValue:paddingInPage], self.bounds.size.height - [self edgeInsetsGetVerticalValue:paddingInPage]);
@@ -303,9 +303,9 @@ - (CGFloat)edgeInsetsGetHorizontalValue:(UIEdgeInsets )insets {
@end
-@interface QEmotionBoardView ()
+@interface QEmotionBoardView ()
/// 用于展示表情面板的竖向滚动 scrollView,布局撑满整个控件
-@property(nonatomic, strong, readonly) QMUIEmotionVerticalScrollView *verticalScrollView;
+@property(nonatomic, strong, readonly) UIEmotionVerticalScrollView *verticalScrollView;
@property(nonatomic, strong) NSMutableArray *> *pagedEmotions;
@property(nonatomic, assign) BOOL debug;
@end
@@ -332,7 +332,7 @@ - (void)didInitializedWithFrame:(CGRect)frame {
self.pagedEmotions = [[NSMutableArray alloc] init];
- _verticalScrollView = [[QMUIEmotionVerticalScrollView alloc] init];
+ _verticalScrollView = [[UIEmotionVerticalScrollView alloc] init];
if (@available(iOS 11, *)) {
self.verticalScrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
@@ -359,7 +359,7 @@ - (void)didInitializedWithFrame:(CGRect)frame {
//输入条的上方添加一行细线
UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.bounds), 1 / [UIScreen mainScreen].scale)];
if (@available(iOS 11.0, *)) {
- NSBundle *bundle = [NSBundle bundleForClass:[QMUIEmotionPageView class]];
+ NSBundle *bundle = [NSBundle bundleForClass:[UIEmotionPageView class]];
lineView.backgroundColor = [UIColor colorNamed:@"q_border223" inBundle:bundle compatibleWithTraitCollection:nil];
} else {
lineView.backgroundColor = [UIColor colorWithRed:223/255.0f green:223/255.0f blue:223/255.0f alpha:1];
@@ -471,8 +471,8 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
}
}
-#pragma mark -
-- (void)emotionPageView:(QMUIEmotionPageView *)emotionPageView didSelectEmotion:(QEmotion *)emotion atIndex:(NSInteger)index {
+#pragma mark -
+- (void)emotionPageView:(UIEmotionPageView *)emotionPageView didSelectEmotion:(QEmotion *)emotion atIndex:(NSInteger)index {
//再回调给vc,之前QMUI官方demo里这里是用的block,为了兼容swift和代码清晰,我修改成了delegate
if ([self.delegate respondsToSelector:@selector(emotionView:didSelectEmotion:atIndex:)]){
NSInteger index = [self.emotions indexOfObject:emotion];
@@ -480,7 +480,7 @@ - (void)emotionPageView:(QMUIEmotionPageView *)emotionPageView didSelectEmotion:
}
}
-- (void)emotionPageViewDidLayoutEmotions:(QMUIEmotionPageView *)emotionPageView {
+- (void)emotionPageViewDidLayoutEmotions:(UIEmotionPageView *)emotionPageView {
[self adjustEmotionsAlpha];
}
diff --git a/QKeyboardEmotionView/Classes/QEmotionHelper.m b/QKeyboardEmotionView/Classes/QEmotionHelper.m
index d6e87d5..7704893 100644
--- a/QKeyboardEmotionView/Classes/QEmotionHelper.m
+++ b/QKeyboardEmotionView/Classes/QEmotionHelper.m
@@ -60,7 +60,10 @@ - (void)setEmotionArray:(NSArray *)emotionArray {
if (!_cacheTotalImageDictionary) {
NSMutableDictionary *emotionImageDictionary = [[NSMutableDictionary alloc] init];
for (QEmotion *e in _emotionArray) {
- e.image = [UIImage imageNamed:e.identifier];
+ if (!e.image) {
+ //建议在外部AppDelegate里就设置好image,不建议走这里
+ e.image = [UIImage imageNamed:e.identifier];
+ }
[emotionImageDictionary setObject:e.image forKey:e.displayName];
}
_cacheTotalImageDictionary = emotionImageDictionary;
diff --git a/QKeyboardEmotionView/Classes/QInputBarView.m b/QKeyboardEmotionView/Classes/QInputBarView.m
index 4b11365..d602775 100755
--- a/QKeyboardEmotionView/Classes/QInputBarView.m
+++ b/QKeyboardEmotionView/Classes/QInputBarView.m
@@ -7,13 +7,13 @@
//
//整个Bar的最小高度(即文字只有1行时候的整条Bar的高度)
-const int UIInputBarViewMinHeight = 56;
+const int UIInputBarViewMinHeight = 58;
//Bar里面的UITextView的最小高度(即文字只有1行时候的UITextView高度)
-const int UIInputTextViewMinHeight = 38;
+const int UIInputTextViewMinHeight = 42;
//Bar里面的UITextView的最大高度(即文字有超多行时候的高度)
-const int UIInputTextViewMaxHeight = 152;
+const int UIInputTextViewMaxHeight = 147;
#import "QInputBarView.h"
#import "UITextView+QEmotion.h"
@@ -60,8 +60,8 @@ - (void)setupWithConfiguration:(QInputBarViewConfiguration *)configuration
{
self.keyboardSendEnabled = configuration.keyboardSendEnabled;
- const int UISwitchButtonWidth = 36; // 3个按钮固定宽高
- const int horizontalPadding = 8; // 水平间隔
+ const int UISwitchButtonWidth = 40; // 3个按钮固定宽高
+ const int horizontalPadding = 6; // 水平间隔
const CGFloat verticalPadding = (UIInputBarViewMinHeight - UISwitchButtonWidth )/2;// 垂直间隔
CGFloat textViewFrameX = 0;// 输入框的frame.x
CGFloat rightViewsMinX = 0;// 输入框右边的按钮的minY,为了计算textView的宽度
@@ -166,6 +166,11 @@ - (void)setupWithConfiguration:(QInputBarViewConfiguration *)configuration
textView.scrollsToTop = NO;
textView.textAlignment = NSTextAlignmentLeft;
textView.layer.cornerRadius = 6.0f;
+ //top, left, bottom, right
+ textView.textContainerInset = UIEdgeInsetsMake(10.0f, 8.0f, 10.0f, 8.0f);
+ //如果我设置了left边距,换行的时候,xcode会弹出提示:requesting caretRectForPosition: while the NSTextStorage has oustanding changes . 但是实际运行没任何影响
+ //如果把left(第2、4个参数)设置为0,就不会有警告。原因不明
+
textView.enablesReturnKeyAutomatically = YES; // UITextView内部判断send按钮是否可以用
}
//本类来控制tv的frame和delegate