Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8349265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:56:28+00:00 2026-06-09T07:56:28+00:00

I can’t get the size of font. Why does my font equal to zero?

  • 0

I can’t get the size of font. Why does my font equal to zero?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
  UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kQuestionIdentifier];
        if (cell == nil)
        {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kQuestionIdentifier] autorelease];
        }

        cell.textLabel.text = [self extractText:indexPath forLabelAttribute:kTextLabel];
        cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
        cell.textLabel.numberOfLines = 0;

        NSLog(@"______font family%@", cell.textLabel.font.familyName);
        NSLog(@"______font name%@", cell.textLabel.font.fontName);
        NSLog(@"______font size%f", cell.textLabel.font.pointSize);

And log:

______font family.Helvetica NeueUI 

______font name.HelveticaNeueUI-Bold

______font size0.000000
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T07:56:30+00:00Added an answer on June 9, 2026 at 7:56 am

    I’ve noticed this issue when the first table view presented is constructed. Subsequent views do not exhibit this behavior in my case. In other words, the font is clearly initialized after tableView:cellForRowAtIndexPath: for the first constructed table view only.

    One way to get around this is to ensure the proper initialization of fonts in the cell constructor:
    Define a new UITableViewCell constructor in a category and create new fonts for the textLabel and detailTextLabel with what ever defaults you choose after calling super initWithStyle:.

    Two construction strategies:

    • only use this new constructor in affected table views, and make
      sure your defaults are consistent with the OS defaults.

    • Alternatively replace all UITableViewCell constructor calls with
      this new constructor to ensure consistency for all table views, and
      omit the check for the pointSize. I would likely side with this strategy since the defaults are subject to change in future OS revisions.

    You can use the defaults listed here as a reference. Although, I think they have changed since iOS 4.2: Default font size of UITableViewCell

    You could alternatively log them using the simulator to discover them yourself in the second UITableView constructed.

    Example code:

    Cell defaults:

    #define kCellStyleSubtitleTextLabelFont @"Helvetica-Bold"
    #define kCellStyleSubtitleTextLabelFontSize 18.0f
    #define kCellStyleSubtitleDetailLabelFont @"Helvetica"
    #define kCellStyleSubtitleDetailLabelFontSize 14.0f
    
    
    #define kCellStyle1TextLabelFont @"Helvetica-Bold"
    #define kCellStyle1TextLabelFontSize 17.0f
    #define kCellStyle1DetailLabelFont @"Helvetica Bold"
    #define kCellStyle1DetailLabelFontSize 15.0f
    
    
    #define kCellStyle2TextLabelFont @"Helvetica-Bold"
    #define kCellStyle2TextLabelFontSize 12.0f
    #define kCellStyle2DetailLabelFont @"Helvetica"
    #define kCellStyle2DetailLabelFontSize 15.0f
    

    UITableViewCell Category:

    @interface UITableViewCell (fontDefaults)
    
    -(id) initWithCellStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier;
    
    @end
    
    #define kCheckPointSize 0
    @implementation UITableViewCell (fontDefaults)
    
    
    -(id) initWithCellStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
        self =  [self initWithStyle:style reuseIdentifier:reuseIdentifier];
    
        if(self == nil)
            return nil;
    
        switch (style) {
    
            case UITableViewCellStyleValue1: { //Left aligned label on left and right aligned label on right with blue text (Used in Settings)
    #if kCheckPointSize    
                if(self.textLabel.font.pointSize == 0)
    #endif    
                    self.textLabel.font = [UIFont fontWithName:kCellStyle1TextLabelFont size:kCellStyle1TextLabelFontSize];
    #if kCheckPointSize    
                if(self.detailTextLabel.font.pointSize == 0)
    #endif    
                    self.detailTextLabel.font = [UIFont fontWithName:kCellStyle1DetailLabelFont size:kCellStyle1DetailLabelFontSize];
    
    
    
                break;
    
            }
    
            case UITableViewCellStyleValue2: { //Right aligned label on left with blue text and left aligned label on right (Used in Phone/Contacts)
    #if kCheckPointSize    
                if(self.textLabel.font.pointSize == 0)
    #endif    
                    self.textLabel.font = [UIFont fontWithName:kCellStyle2TextLabelFont size:kCellStyle2TextLabelFontSize];
    #if kCheckPointSize    
                if(self.detailTextLabel.font.pointSize == 0)
    #endif    
                    self.detailTextLabel.font = [UIFont fontWithName:kCellStyle2DetailLabelFont size:kCellStyle2DetailLabelFontSize];
    
                break;
    
            }
    
            case UITableViewCellStyleSubtitle: { //Left aligned label on top and left aligned label on bottom with gray text (Used in iPod).
    #if kCheckPointSize    
                if(self.textLabel.font.pointSize == 0)
    #endif    
                    self.textLabel.font = [UIFont fontWithName:kCellStyleSubtitleTextLabelFont size:kCellStyleSubtitleTextLabelFontSize];
    #if kCheckPointSize    
                if(self.detailTextLabel.font.pointSize == 0)
    #endif    
                    self.detailTextLabel.font = [UIFont fontWithName:kCellStyleSubtitleDetailLabelFont size:kCellStyleSubtitleDetailLabelFontSize];
    
                break;
    
            }
    
            default: //default cell style
            case UITableViewCellStyleDefault: { //Simple cell with text label and optional image view (behavior of UITableViewCell in iPhoneOS 2.x).  No detailTextLabel
    #if kCheckPointSize
                if(self.textLabel.font.pointSize == 0) //
    #endif    
                    self.textLabel.font = [UIFont fontWithName:kCellStyle1TextLabelFont size:kCellStyle1TextLabelFontSize];
    
    
    
                break;
    
            }
    
        }
    
        return self;
    
    }
    
    
    @end
    

    Example construction in tableView:cellForRowAtIndexPath:

    static NSString *CellIdentifier = @"Style2Cell";
    
    
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
    if (cell == nil) {
    
        cell = [[[UITableViewCell alloc]
    
                  initWithCellStyle:UITableViewCellStyleValue2
    
                 reuseIdentifier:CellIdentifier] autorelease];
    
    
    
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    
    
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I change the field public virtual ClassOne ClassOne { get; set; } to
Can any one tell, how to get the result of LINQ query contains group
Can someone tell me how does the imdb app manage to play trailers on
Can't seem to get the Back Button to appear in a UINavigationController flow. I
Does anyone know how can I replace this 2 symbol below from the string
Can i get the source code for a WAMP stack installer somewhere? Any help
Can I somehow see the types and size of the contents of a tuple?
Can it be done? Does Facebook API support defining new custom fields / objects
Can anyone let me know how can we change the value of kendo combobox
Can I order my users in the database, so I don't have to say

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.