diff --git a/ChatExample/ChatExample.xcodeproj/project.pbxproj b/ChatExample/ChatExample.xcodeproj/project.pbxproj
index 6aaf648..91b538e 100644
--- a/ChatExample/ChatExample.xcodeproj/project.pbxproj
+++ b/ChatExample/ChatExample.xcodeproj/project.pbxproj
@@ -132,7 +132,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0920;
- LastUpgradeCheck = 0920;
+ LastUpgradeCheck = 0930;
ORGANIZATIONNAME = "Andrey Ivanov";
TargetAttributes = {
FB9EA92320614E2300E3FF45 = {
@@ -282,6 +282,7 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
@@ -289,6 +290,7 @@
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -339,6 +341,7 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
@@ -346,6 +349,7 @@
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
diff --git a/ChatExample/ChatExample/Base.lproj/Main.storyboard b/ChatExample/ChatExample/Base.lproj/Main.storyboard
index 7de1907..1986c7d 100644
--- a/ChatExample/ChatExample/Base.lproj/Main.storyboard
+++ b/ChatExample/ChatExample/Base.lproj/Main.storyboard
@@ -61,6 +61,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -85,43 +105,57 @@
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
-
+
+
-
-
-
+
+
+
-
+
-
+
-
+
-
+
@@ -140,4 +174,7 @@
+
+
+
diff --git a/ChatExample/ChatExample/ChatViewController.swift b/ChatExample/ChatExample/ChatViewController.swift
index c215a10..db140e3 100644
--- a/ChatExample/ChatExample/ChatViewController.swift
+++ b/ChatExample/ChatExample/ChatViewController.swift
@@ -48,8 +48,6 @@ class ChatViewController: QMChatViewController {
self.finishSendingMessage(animated: true)
}
-// override inputtoolbar
-
override func viewClass(forItem item: QBChatMessage) -> AnyClass {
if item.isDateDividerMessage {
@@ -60,9 +58,9 @@ class ChatViewController: QMChatViewController {
}
}
-
-
- override func collectionView(_ collectionView: QMChatCollectionView!, dynamicSizeAt indexPath: IndexPath!, maxWidth: CGFloat) -> CGSize {
+ override func collectionView(_ collectionView: QMChatCollectionView!,
+ dynamicSizeAt indexPath: IndexPath!,
+ maxWidth: CGFloat) -> CGSize {
let size = TTTAttributedLabel.sizeThatFitsAttributedString(self.attributedString(forItem: self.chatDataSource.message(for: indexPath)),
withConstraints: CGSize(width:maxWidth, height:1000),
@@ -70,7 +68,8 @@ class ChatViewController: QMChatViewController {
return size
}
- override func collectionView(_ collectionView: QMChatCollectionView!, minWidthAt indexPath: IndexPath!) -> CGFloat {
+ override func collectionView(_ collectionView: QMChatCollectionView!,
+ minWidthAt indexPath: IndexPath!) -> CGFloat {
let msg = self.chatDataSource.message(for: indexPath)
let viewClass: AnyClass = self.viewClass(forItem: msg!)
diff --git a/QMChatViewController/QMChatViewController.h b/QMChatViewController/QMChatViewController.h
index e31509e..02e411e 100644
--- a/QMChatViewController/QMChatViewController.h
+++ b/QMChatViewController/QMChatViewController.h
@@ -38,8 +38,9 @@
#import "QMChatIncomingLinkPreviewCell.h"
#import "QMChatOutgoingLinkPreviewCell.h"
-@interface QMChatViewController : UIViewController
+NS_ASSUME_NONNULL_BEGIN
+@interface QMChatViewController : UIViewController
@property (strong, nonatomic) QMChatDataSource *chatDataSource;
/**
@@ -108,7 +109,7 @@
*
* @return Configured attributed string.
*/
-- (NSAttributedString *)attributedStringForItem:(QBChatMessage *)messageItem;
+- (nullable NSAttributedString *)attributedStringForItem:(QBChatMessage *)messageItem;
/**
* Method to create chat message top label attributed string (Usually - chat message owner name). Have to be overriden in subclasses.
@@ -117,7 +118,7 @@
*
* @return Configured attributed string.
*/
-- (NSAttributedString *)topLabelAttributedStringForItem:(QBChatMessage *)messageItem;
+- (nullable NSAttributedString *)topLabelAttributedStringForItem:(QBChatMessage *)messageItem;
/**
* Method to create chat message bottom label attributed string (Usually - chat message date sent). Have to be overriden in subclasses.
@@ -126,7 +127,7 @@
*
* @return Configured attributed string.
*/
-- (NSAttributedString *)bottomLabelAttributedStringForItem:(QBChatMessage *)messageItem;
+- (nullable NSAttributedString *)bottomLabelAttributedStringForItem:(QBChatMessage *)messageItem;
/**
* Collection Cell View class for specific message. Have to be overriden in subclasses. Defaults cells are supplied with QMChatViewController.
@@ -250,6 +251,11 @@
*/
- (void)finishReceivingMessageAnimated:(BOOL)animated;
+/**
+ Input bar start pos
+ */
+- (NSUInteger)inputToolBarStartPos;
+
/**
* Scrolls the collection view such that the bottom most cell is completely visible, above the `inputToolbar`.
*
@@ -280,3 +286,5 @@
- (void)viewWillAppear:(BOOL)animated NS_REQUIRES_SUPER;
@end
+
+NS_ASSUME_NONNULL_END
diff --git a/QMChatViewController/QMChatViewController.m b/QMChatViewController/QMChatViewController.m
index e2099e3..f6b72bf 100644
--- a/QMChatViewController/QMChatViewController.m
+++ b/QMChatViewController/QMChatViewController.m
@@ -93,8 +93,8 @@ - (void)viewDidLoad {
self.systemInputToolbar.frame = CGRectMake(0, 0, 0, kQMSystemInputToolbarDebugHeight);
self.systemInputToolbar.hostViewFrameChangeBlock = ^(UIView *view, BOOL animated) {
- CGFloat pos = view.superview.frame.size.height - view.frame.origin.y ;
-
+ CGFloat pos = weakSelf.view.frame.size.height - [view.superview convertPoint:view.frame.origin toView:weakSelf.view].y;
+
if (weakSelf.inputToolbar.contentView.textView.isFirstResponder) {
if (view.superview.frame.origin.y > 0 && pos == 0) {
@@ -103,11 +103,11 @@ - (void)viewDidLoad {
}
const CGFloat v = [weakSelf inputToolBarStartPos];
-
- if (pos < v ) {
+
+ if (pos < v || !view) {
pos = v;
}
-
+
[weakSelf setToolbarBottomConstraintValue:pos animated:animated];
};
@@ -282,11 +282,7 @@ - (void)chatDataSource:(QMChatDataSource *)chatDataSource willBeChangedWithMessa
#pragma mark - View lifecycle
- (NSUInteger)inputToolBarStartPos {
-
- if (self.tabBarItem) {
- return self.tabBarController.tabBar.frame.size.height;
- }
-
+
return 0;
}
@@ -798,7 +794,6 @@ - (void)setToolbarBottomConstraintValue:(CGFloat)constraintValue animated:(BOOL)
self.toolbarBottomLayoutGuide.constant = constraintValue;
if (animated) {
-
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
diff --git a/QMChatViewController/Views/Cells/QMChatContactRequestCell/QMChatContactRequestCell.xib b/QMChatViewController/Views/Cells/QMChatContactRequestCell/QMChatContactRequestCell.xib
index 6c40ad2..99fc1f6 100644
--- a/QMChatViewController/Views/Cells/QMChatContactRequestCell/QMChatContactRequestCell.xib
+++ b/QMChatViewController/Views/Cells/QMChatContactRequestCell/QMChatContactRequestCell.xib
@@ -1,11 +1,11 @@
-
+
-
-
+
+
@@ -25,10 +25,10 @@
-
+