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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:22:59+00:00 2026-06-09T20:22:59+00:00

My text is two lines long in portrait mode. When I switch to landscape

  • 0

My text is two lines long in portrait mode. When I switch to landscape mode, it fits into a single line. I’m using static tableview cells via a storyboard; how can I resize the row to fit snugly?

The screen is a signin screen.

  • The first cell contains some explanation text
  • The second is a text field for entering the account name
  • The third is a secure text field for entering the password
  • The fourth (and last) cell contains the signin button. The return key on the keyboard submits the form or switches the focus as appropriate
  • 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-09T20:23:01+00:00Added an answer on June 9, 2026 at 8:23 pm

    Use UITableView's heightForRowAtIndexPath :

     - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
     {
       int topPadding = 10;
       int bottomPadding = 10;
       float landscapeWidth = 400;
       float portraitWidth = 300;
    
       UIFont *font = [UIFont fontWithName:@"Arial" size:22];
    
       //This is for first cell only if you want for all then remove below condition
       if (indexPath.row == 0) // for cell with dynamic height
       {
          NSString *strText = [[arrTexts objectAtIndex:indexPath.row]; // filling text in label  
         if(landscape)//depends on orientation
         {
           CGSize maximumSize = CGSizeMake(landscapeWidth, MAXFLOAT); // change width and height to your requirement
         }
         else //protrait
         {
           CGSize maximumSize = CGSizeMake(portraitWidth, MAXFLOAT); // change width and height to your requirement
         }
    
         //dynamic height of string depending on given width to fit
         CGSize textSize = CGSizeZero;
         if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")
         {
            NSMutableParagraphStyle *pstyle = [NSMutableParagraphStyle new];
            pstyle.lineBreakMode = NSLineBreakByWordWrapping;
    
            textSize = [[strText boundingRectWithSize:CGSizeMake(width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName :font,NSParagraphStyleAttributeName:[pstyle copy]} context:nil] size];
         }
         else // < (iOS 7.0)
         {
            textSize = [strText sizeWithFont:font constrainedToSize:maximumSize lineBreakMode:NSLineBreakByWordWrapping] 
         }
    
         return (topPadding+textSize.height+bottomPadding) // caculate on your bases as u have string height
       }
       else
       {
           // return height from the storyboard
           return [super tableView:tableView heightForRowAtIndexPath:indexPath];
       }
     }
    

    EDIT : Added for support for > and < ios7 and as sizeWithFont method is deprecated in iOS 7.0

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

Sidebar

Related Questions

I want this text all on one line, not spaced on two sepearate lines.
I have some static text that is usually only 1 line long that displays
I have two lines of text which have long space (more like 14-15 spaces)
I try to align an image (a logo) with a text in two lines
How to get complementary lines from two text files? File file1.txt has 123 foo
I have a UILabel with space for two lines of text. Sometimes, when the
Is it possible to take only the first two lines from a wrapped text
I have a text file containing two or more types of lines. I would
I have two 3GB text files, each file has around 80 million lines. And
I have to filter a text file filter.tmp containing two types of lines, this

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.