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 387291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:39:33+00:00 2026-05-12T15:39:33+00:00

I’m trying to put a text badge on my Iphone app with the undocumented

  • 0

I’m trying to put a text badge on my Iphone app with the undocumented setApplicationBadgeString method. The problem I’m having is getting the number of characters right. Sometimes I can fit characters, sometimes it replaces part of my string with dots. I’ve seen the same behaviour on UILabel too, if the text doesn’t fit, it gets cut off by “…”. How can I programmatically find out when the text will get truncated in the specific case of the text badge, as I have no way to check its size – it actually appears not to be constant. Thank you!

  • 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-05-12T15:39:33+00:00Added an answer on May 12, 2026 at 3:39 pm

    The number of charachters varies because the width of the characters varies. a W is longer than an *l**, so a bunch of W’s will be truncated sooner than a bunch of l’s.

    Through trial and error you could use NSString‘s method – (CGSize)sizeWithFont:(UIFont *)font to find out the maximum width allowed on a badge. You will have to figure out what font size the badge uses though. Your code would should end up looking something like this…

    // I'm not sure what the badge font size is, you will have to test for this
    UIFont *font = [UIFont systemFontOfSize:12];
    
    // Keep adding 1's to the badge string until you get the ...'s, then you will 
    // know the maximum size of the badge string!
    NSString *badgeString = @"111";     
    NSLog(@"width: %f", [badgeString sizeWithFont:font].width);
    
    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:badgeString];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from
I am trying to loop through a bunch of documents I have to put
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:

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.