修复 JSQMessagesViewController 的 textView 的大小

Fixing the size of textView of JSQMessagesViewController

我试过更改下面的代码,评论 textContainerInset 和 contentInset,无法找出当我添加文本时容器的框架如何变化,textView 的委托中似乎也没有任何内容。

- (void)jsq_configureTextView
{
   [self setTranslatesAutoresizingMaskIntoConstraints:NO];

    CGFloat cornerRadius = 6.0f;

    self.backgroundColor = [UIColor whiteColor];
    self.layer.borderWidth = 0.5f;
    self.layer.borderColor = [UIColor lightGrayColor].CGColor;
    self.layer.cornerRadius = cornerRadius;

    self.scrollIndicatorInsets = UIEdgeInsetsMake(cornerRadius, 0.0f, cornerRadius, 0.0f);

    self.textContainerInset = UIEdgeInsetsMake(4.0f, 2.0f, 4.0f, 2.0f);
    self.contentInset = UIEdgeInsetsMake(1.0f, 0.0f, 1.0f, 0.0f);

    self.scrollEnabled = YES;

    self.scrollsToTop = NO;
    self.userInteractionEnabled = YES;

    self.font = [UIFont systemFontOfSize:16.0f];
    self.textColor = [UIColor blackColor];
    self.textAlignment = NSTextAlignmentNatural;

    self.contentMode = UIViewContentModeRedraw;
    self.dataDetectorTypes = UIDataDetectorTypeNone;
    self.keyboardAppearance = UIKeyboardAppearanceDefault;
    self.keyboardType = UIKeyboardTypeDefault;
    self.returnKeyType = UIReturnKeyDefault;

    self.text = nil;

    _placeHolder = nil;
    _placeHolderTextColor = [UIColor lightGrayColor];

    [self jsq_addTextViewNotificationObservers];
}

设置JSQMessagesViewController的inputToolbar的maximumHeight即可。

self.inputToolbar.maximumHeight = 44