Tencent / QMUI_iOS

QMUI iOS——致力于提高项目 UI 开发效率的解决方案

Home Page:http://qmuiteam.com/ios

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

可能是QMUITextView 引起的闪退

YuStephen opened this issue · comments

Bug 表现
线上用户反馈的报错,无法复现,根据用户反馈,是在点击输入框的时候造成的闪退。猜测,可能是QMUITextView在修改自身高度的时候引起的,下面贴了报错的堆栈信息和相关代码。诸位看看到底是因为什么原因,抱拳!

截图
Bug 现场的界面截图,或者 Xcode 控制台的错误信息截图,有问题的代码截图
image

初始化
self.textView = [[QMUITextView alloc] initWithFrame:CGRectZero];
self.textView.font = UIFontMake(14);
self.textView.maximumHeight = 100;
self.textView.textColor = UIColor.ts_themeDescriptionTextColor;
self.textView.backgroundColor = UIColorMakeWithHex(@"#F6F6F6");
self.textView.layer.cornerRadius = 18;
self.textView.textContainerInset = UIEdgeInsetsMake(10, 7, 10, 35);
self.textView.returnKeyType = UIReturnKeySend;
self.textView.enablesReturnKeyAutomatically = YES;
self.textView.delegate = self;
[self.topContainerView addSubview:self.textView];

[self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.equalTo(self.voiceButton.mas_right).offset(10);
    make.right.equalTo(-20);
    make.height.equalTo(self.currentTextViewHeight);
    make.top.equalTo(12);
    make.bottom.equalTo(-12);
}];

修改高度

  • (void)textView:(QMUITextView *)textView newHeightAfterTextChanged:(CGFloat)height {
    height = fmax(height, 37);
    BOOL needsChangeHeight = CGRectGetHeight(textView.frame) != height;
    if (needsChangeHeight) {
    self.currentTextViewHeight = height;
    [self.textView mas_updateConstraints:^(MASConstraintMaker *make) {
    make.height.offset(height);
    }];
    }
    }

其他信息

  • 设备: [iPhone]
  • iOS 版本: [iOS 15.0]
  • Xcode 版本: [Xcode 15.2]
  • QMUI 版本: [4.7.0]

不是QMUI的问题