iOS 8 - Crash
sergisolanellas opened this issue · comments
Inside of method "UpdateText", the line "_textView.textContainer.lineFragmentPadding = 0;" crashes.
I need to test app with iOS8, and I repaired with this code ( while you revise the problem ):
- (void)updateText
{
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:_cleanText];
[attributedString setAttributes:_attributesText range:NSMakeRange(0, _cleanText.length)];
for (NSDictionary *dictionary in _rangesOfHotWords) {
NSRange range = [[dictionary objectForKey:@"range"] rangeValue];
STTweetHotWord hotWord = (STTweetHotWord)[[dictionary objectForKey:@"hotWord"] intValue];
[attributedString setAttributes:[self attributesForHotWord:hotWord] range:range];
}
[_textStorage appendAttributedString:attributedString];
_textContainer = [[NSTextContainer alloc] initWithSize:CGSizeMake(self.frame.size.width, CGFLOAT_MAX)];
[_layoutManager addTextContainer:_textContainer];
[_textStorage addLayoutManager:_layoutManager];
if (_textView != nil)
[_textView removeFromSuperview];
_textView = [[UITextView alloc] initWithFrame:self.bounds textContainer:_textContainer];
_textView.delegate = self;
_textView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
_textView.backgroundColor = [UIColor clearColor];
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_8_0
// iOS 8+ code here
#else
// Pre iOS 8 code here
_textView.textContainer.lineFragmentPadding = 0;
_textView.textContainerInset = UIEdgeInsetsZero;
#endif
_textView.userInteractionEnabled = NO;
[self addSubview:_textView];
}
Hello Sergi,
Thank you for this bug report and also for the potential fix. I will take a look to this issue the next few days/weeks. I'm waiting the next betas. I don't like "fixing" a problem with a first beta. The goal is to launch STTweetLabel 4.0 in August/September written in Swift.
Once again, thank you for your help!
Hello Sebastien,
I tried XCode6 Beta5 and it happens the same problem. I don't know how to fix it, but it seems the problem is something about execute this method without main thread. It's possible?
Thanks :)
Hello all,
Trying to fix your problem but I cannot reproduce it with iOS 8 beta 5. Any steps to reproduce it?
I use STTweetlabel inside cellForRowAtIndexPath like this:
'
STTweetLabel *LDescrip = [[STTweetLabel alloc] initWithFrame:CGRectMake(20, 88, 280, [self heightStringWithEmojis:[[allHeader objectAtIndex:0] descrip] fontType:[UIFont fontWithName:@"HelveticaNeue" size:16.0] ForWidth:280])];
__typeof(self) __weak weakSelf = self;
[LDescrip setDetectionBlock:^(STTweetHotWord hotWord, NSString *string, NSString *protocol, NSRange range) {
switch (hotWord) {
case STTweetHandle:
[weakSelf openPerfilUser:string];
break;
case STTweetHashtag:
// Do nothing
break;
case STTweetLink:
[weakSelf openHTMLLink:string];
break;
}
}];
[LDescrip setText:[[allHeader objectAtIndex:0] descrip]];
[LDescrip setFont:[UIFont fontWithName:@"HelveticaNeue" size:16]];
[LDescrip setTextColor:[UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1.0]];
[LDescrip setNumberOfLines:0];
[LDescrip setBackgroundColor:[UIColor clearColor]];
[cell.contentView addSubview:LDescrip];
'
Solution provided here, might be helpful... http://openradar.io/17623734
@JyothiSwaroop link not working