At first, i'm sorry for my poor English.
This crash Only happend on iOS 10.2.1, others devices or simulators are fine. Because i don't have iOS 10.2.1 device or simulator, there is no way to reproduce. Here is Crash Log (Github link).
What i did was fetch data from server and reloadData
by UITableView
. Crashed while reloadData
.
All of operation are in main queue block.
Some code in UITableViewCell
as below:
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { [self.contentView addSubview:self.avatarImageView]; [self.contentView addSubview:self.messageBackgroundView]; [self.messageBackgroundView addSubview:self.messageTextView]; } return self;}+ (BOOL)requiresConstraintBasedLayout { return YES;}- (void)prepareForReuse { [super prepareForReuse]; [self.messageBackgroundView mas_remakeConstraints:^(MASConstraintMaker *make) { }];}- (void)updateConstraints { [self.avatarImageView mas_remakeConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(CGSizeMake(38, 38)); make.top.equalTo(self.contentView.mas_top).offset(9).priorityHigh(); if (self.myself) { make.trailing.equalTo(self.contentView.mas_trailing).offset(-18); } else { make.leading.equalTo(self.contentView.mas_leading).offset(18); } }]; [self.messageBackgroundView mas_remakeConstraints:^(MASConstraintMaker *make) { if (self.myself) { make.trailing.equalTo(self.avatarImageView.mas_leading).offset(-9); make.leading.mas_greaterThanOrEqualTo(self.contentView.mas_leading).offset(44); } else { make.leading.equalTo(self.avatarImageView.mas_trailing).offset(9); make.trailing.mas_lessThanOrEqualTo(self.contentView.mas_trailing).offset(-44); } make.top.equalTo(self.avatarImageView.mas_top); make.bottom.equalTo(self.contentView.mas_bottom).offset(-9).priorityHigh(); }]; [self.messageTextView mas_updateConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(self.messageBackgroundView).insets(UIEdgeInsetsMake(8, 14, 8, 14)); make.height.equalTo(@(self.textViewHeight)); }]; [super updateConstraints];}- (void)setMessage:(GWBaseModel *)message { _message = message; // ... update ui, set height for textview [self setNeedsUpdateConstraints];}
Any other infomation you need, please leave a comment. I will reply quickly. Thanks for your kindly helping.