RTLabel
RTLabel copied to clipboard
optimumSize
optimumSize crashes, with: code=EXC_ARM_BREAKPOINT, subcode=0xdefe
label content is: "ENERGIEWENDE IN DEUTSCHLAND" Here is the code (sorry for junk code):
RTLabel *tv = [[RTLabel alloc] init];
if([contentElement attributeNamed:@"line-height"]){
[tv setLineSpacing:[[contentElement attributeNamed:@"line-height"] floatValue]];
}
[tv setText:[contentElement value]];
if([contentElement attributeNamed:@"line-height"]){
[tv setLineSpacing:[[contentElement attributeNamed:@"line-height"] floatValue]];
}
[tv setTag:[[contentElement attributeNamed:@"id"] intValue]];
[tv setTranslatesAutoresizingMaskIntoConstraints:NO];
UIFont *font;
if(fontName && [contentElement attributeNamed:@"size"]){
font = [UIFont fontWithName:fontName size:[[contentElement attributeNamed:@"size"] intValue]];
}else{
font = [UIFont fontWithName:fontName size:16];
}
[tv setFont:font];
if([[contentElement attributeNamed:@"align"] isEqualToString:@"left"]){
tv.textAlignment = NSTextAlignmentLeft;
}else if([[contentElement attributeNamed:@"align"] isEqualToString:@"right"]){
tv.textAlignment = NSTextAlignmentRight;
}else{
tv.textAlignment = NSTextAlignmentLeft;
}
if([contentElement attributeNamed:@"color"]){
unsigned result = 0;
NSScanner *scanner = [NSScanner scannerWithString:[contentElement attributeNamed:@"color"]];
[scanner scanHexInt:&result];
UIColor *color = UIColorFromRGB(result);
if(invertedColors){
[tv setTextColor:[color inverseColor]];
}else{
[tv setTextColor:color];
}
}else{
if(invertedColors){
[tv setTextColor:[UIColor whiteColor]];
}else{
[tv setTextColor:[UIColor blackColor]];
}
}
[tv setBackgroundColor:[UIColor clearColor]];
tv.lineBreakMode = NSLineBreakByWordWrapping; // or some other desired wrapping
if(width == 350){
CGRect frame = CGRectMake(0, 0, 350 - [[pageContent attributeNamed:@"margin"] floatValue], 9999); // oversized height
tv.frame = frame;
}else{
CGRect frame = CGRectMake(0, 0, 1024, 9999); // oversized height
tv.frame = frame;
}
[containerView addSubview:tv];
CGSize optimumSize = [tv optimumSize];
I am also facing same problem. have to found any solution
I had the same issue, found solution after initialization of RTlLabel with frame of height 100.
RTLabel *yourLabel = [[RTLabel alloc] initWithFrame:CGRectMake(0,0,100,100)]; then assign text n get optimize height and update frame of yourLabel.
Same problem here.