当前知识库站点已不再维护。请移步新版知识库:https://help.rongcloud.cn/

隐藏聊天页面输入框方法

单独只隐藏输入框,会导致页面下方有空白出现,所以还需要设置其他 UI 的 frame 来配合实现。
发布时间: 2019-07-24 11:16

回答:

实现思路:


  1. 设置输入框的“隐藏”属性为 YES。

  2. 修改 self.view 的背景色。

  3. 将消息滚动到最下方。

  4. 设置 self.conversationMessageCollectionView 的 frame。


实现代码:


- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    //隐藏输入框并修改背景色
    self.chatSessionInputBarControl.hidden = YES;
    self.view.backgroundColor = self.conversationMessageCollectionView.backgroundColor;
    [self scrollToBottomAnimated:NO];
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    CGRect frame = self.conversationMessageCollectionView.frame;
    frame.size.height += self.chatSessionInputBarControl.frame.size.height;
    self.conversationMessageCollectionView.frame = frame;
}