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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:21:22+00:00 2026-05-27T22:21:22+00:00

I am displaying a long string using UILabel with UILineBreakModeWordWrap . It is showing

  • 0

I am displaying a long string using UILabel with UILineBreakModeWordWrap. It is showing the string perfectly by wrapping text in UILabel. I want to access last line of UILabel. Does anyone know how to do this on an iPhone?

  • 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-27T22:21:23+00:00Added an answer on May 27, 2026 at 10:21 pm

    So I tried some stuff and searched a little around. What you wuld actually need is to count the word wraps and somehow detect the last string. But I didnt really figuere out how to do that.

    So my sollution is something like this:

    Your String //I googled some longer String

     NSString *string = @"Standing across the room, I saw you smile\nSaid I want to talk to you-oo-oo for a little while\nBut before I make my move my emotions start running wild\nMy tongue gets tied and that's no lie\nLooking in your eyes\nLooking in you big brown eyes ooh yeah\nAnd I've got this to say to you\nHey!\nGirl I want to make you sweat\nSweat till you can't sweat no more\nAnd if you cry out\nI'm gonna push it some, more, more\nGirl I want to make you sweat\nSweat till you can't sweat no more\nAnd if you cry out\nI'm gonna push it\nPush it, push it some more";
    

    Your Label:

    UILabel *label          = [[UILabel alloc] initWithFrame:CGRectMake(20, 20, 280, 440)];
    label.font              = [UIFont fontWithName:@"Helvetica" size:14];
    label.lineBreakMode     = UILineBreakModeWordWrap;
    label.numberOfLines     = 0;
    label.backgroundColor   = [UIColor clearColor];
    label.textColor         = [UIColor blackColor];
    label.text              = string;
    

    The call this Method:

    NSString *result = [self getLastLineFromString:string];
    NSLog(@"Result: %@", result);
    

    getLastLineFromString: looks like this:

    - (NSString *)getLastLineFromString: (NSString *)string{
        NSArray *a = [string componentsSeparatedByString:@" "];
        NSString *result = [a objectAtIndex:[a count]-1];
        NSString *temp = @"";
        int count = 1;
        BOOL myBool = YES;
        while (myBool) {
            count++;
    
            temp = result;
            result = [a objectAtIndex:[a count] -count];
            result = [NSString stringWithFormat:@"%@ %@", result, temp];
            NSLog(@"length: %i",[self lengthOfString:result]);
            NSLog(@"result: %@",result);
    
        //131 was a value i detected mayels, i guess u have do trick a little around to find a mathcing one for yourself
        if ([self lengthOfString:result] >= 131) {
            myBool = NO;
        }
        }
        return result;
    }
    

    And The MethodlengthOfString: looks like this:

    - (int)lengthOfString:(NSString *)string{
        CGSize size1 = [string sizeWithFont:[UIFont fontWithName:@"Helvetica" size:14]];
        return size1.width;
    }
    

    Output:

    2012-01-06 16:17:08.341 get length[5472:207] result: it
    Push it, push it some more
    

    I know this is not a perfect sollution, but it might help you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a Forms application I'm displaying log output from a long running command-line application
I am using JQuery Mobile and have an <LI> with some long text (A
I have a long path I'd like to shorten for displaying on a form
Displaying Type here to ... until the user enters text into a TextBox is
When displaying my DateTime values, I want them to be formatted like so: February
I'm displaying a set of images as an overlay using Google Maps. Displaying these
I am displaying a texture that I want to manipulate without out affecting the
I have a JScrollPane that holds a JLabel using the following code: //Create TEXT
Short: how does modelbinding pass objects from view to controller? Long: First, based on
I am displaying some text in a column inside an SPGridView. The text happens

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.