0

I have this line code.

 CGSize size = [(text ? text : @"") sizeWithFont:font constrainedToSize:CGSizeMake(220, 9999) lineBreakMode:NSLineBreakByWordWrapping];

And the function sizeWithFont was deprecated.

After search here i found this solution. Replace the deprecation sizeWithFont:minFontSIze:actualFontSize in ios 7

And I use this method :

-(CGSize)frameForText:(NSString*)text sizeWithFont:(UIFont*)font constrainedToSize:(CGSize)size lineBreakMode:(NSLineBreakMode)lineBreakMode  {

NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy];
paragraphStyle.lineBreakMode = lineBreakMode;

NSDictionary * attributes = @{NSFontAttributeName:font,
                              NSParagraphStyleAttributeName:paragraphStyle
                              };


CGRect textRect = [text boundingRectWithSize:size
                                     options:NSStringDrawingUsesLineFragmentOrigin
                                  attributes:attributes
                                     context:nil];

//Contains both width & height ... Needed: The height
return textRect.size;

}

But I still do not understand something in my code that I found so I can not restore the original line

What this line code does? (text ? text : @"")

How can I send this to the frameForText function for it to work for me?

Community
  • 1
  • 1
Roei Nadam
  • 1,780
  • 1
  • 15
  • 33
  • 1
    `(text ? text: @"")` is a ternary operator have a look at this question for more info. http://stackoverflow.com/questions/2595392/what-does-the-question-mark-and-the-colon-ternary-operator-mean-in-objectiv – sbarow Oct 20 '14 at 09:08
  • Ok ,and you know how I can sent this for the frameForText Without changing the original line ? – Roei Nadam Oct 20 '14 at 09:21
  • 1
    `[self frameForText:(text ? text : @"") sizeWithFont:font constrainedToSize:CGSizeMake(220, 9999) lineBreakMode:NSLineBreakByWordWrapping];` is what I think you are asking? – sbarow Oct 20 '14 at 09:23

0 Answers0