mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-30 16:22:39 +00:00
Console: Fixed UITextView creation on non UI thread
This commit is contained in:
parent
6ebbc6ebc2
commit
d6dab31b5c
1 changed files with 2 additions and 2 deletions
|
@ -235,15 +235,15 @@ static NSAttributedString *messageSeparator = nil;
|
|||
if (_messageType == RoomMessageTypeText) {
|
||||
if (self.attributedTextMessage.length) {
|
||||
// Use a TextView template to compute cell height
|
||||
UITextView *dummyTextView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, _maxTextViewWidth, MAXFLOAT)];
|
||||
|
||||
// The following code only run on the main thread
|
||||
if([NSThread currentThread] != [NSThread mainThread]) {
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
||||
UITextView *dummyTextView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, _maxTextViewWidth, MAXFLOAT)];
|
||||
dummyTextView.attributedText = self.attributedTextMessage;
|
||||
_contentSize = [dummyTextView sizeThatFits:dummyTextView.frame.size];
|
||||
});
|
||||
} else {
|
||||
UITextView *dummyTextView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, _maxTextViewWidth, MAXFLOAT)];
|
||||
dummyTextView.attributedText = self.attributedTextMessage;
|
||||
_contentSize = [dummyTextView sizeThatFits:dummyTextView.frame.size];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue