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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:42:38+00:00 2026-05-20T04:42:38+00:00

Possible Duplicate: How can i fix my scrollView dynamically when i have more than

  • 0

Possible Duplicate:
How can i fix my scrollView dynamically when i have more than one textViews in it?

I made a scrollView in interface builder and put 3 textViews and 2 button in that. Sometimes textViews have more text and sometimes less. i managed to give them flexible frame size. but if top textView has more text then some of its text comes over 2nd textView. i tried this code. i think it should work but its not working properly.

    storyTitle.text = sTitle;
storyTitle.font = [UIFont boldSystemFontOfSize:18];

date.text = sDate;  
    date.font = [UIFont systemFontOfSize:16];

summary.text = sSummary;
summary.font = [UIFont systemFontOfSize:16];

CGRect titleFrame = storyTitle.frame;
titleFrame.size.height = storyTitle.contentSize.height;
storyTitle.frame = titleFrame;

CGRect dateFrame = date.frame;
dateFrame.size.height = label.contentSize.height;
date.frame = dateFrame;

CGRect summaryFrame = summary.frame;
summaryFrame.size.height = summary.contentSize.height;
summary.frame = summaryFrame;

CGRect topTextViewFrame = storyTitle.frame;
CGRect middleTextViewFrame = date.frame;
NSLog(@"size: %d",topTextViewFrame.origin.y);
middleTextViewFrame.origin.y = topTextViewFrame.origin.y + topTextViewFrame.size.height;
CGRect bottomTextViewFrame = summary.frame;
bottomTextViewFrame.origin.y = middleTextViewFrame.origin.y + middleTextViewFrame.size.height;

   // then adjust other controls based on these frames, for example:
CGRect myButtonFrame = detailButton.frame;
myButtonFrame.origin.y = bottomTextViewFrame.origin.y + bottomTextViewFrame.size.height;

CGRect myButtonFrame2 = fbButton.frame;
myButtonFrame2.origin.y = myButtonFrame.origin.y + myButtonFrame.size.height;

// finally adjust the contentSize of the scrollview assuming the button is the bottom element
CGSize csize = scrollView.contentSize;
csize.height = myButtonFrame2.origin.y + myButtonFrame2.size.height;
scrollView.contentSize = csize;

can anyone tell me whats wrong with this? and how should i right it so it ll work fine. thanx in advance

  • 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-20T04:42:38+00:00Added an answer on May 20, 2026 at 4:42 am

    hi if your text is not editable by user the try using UILabel instead of UITextView.If you set numberOfLines property of UILabel = 0 then it can go to more that one line and then u can calculate the required height for the label by the method

    CGSize size = [label.text sizeWithFont:label.font constrainedToSize:CGSizeMake(label.frame.size.width, FLT_MAX) lineBreakMode:UILineBreakModeWordWrap ];
    

    the u can set the frame of label according to height you get form here like

     label.frame = CGRectMake(label.frame.origin.x,label.frame.origin.y,label.frame.size.width,size.height);
    

    and if you have such multiple labels the uyou can do following

    CGSize size = [label1.text sizeWithFont:label1.font constrainedToSize:CGSizeMake(label1.frame.size.width, FLT_MAX) lineBreakMode:UILineBreakModeWordWrap ];
    label1.frame =   CGRectMake(label1.frame.origin.x,label1.frame.origin.y,label1.frame.size.width,size.height);
    
    size = [label2.text sizeWithFont:label2.font constrainedToSize:CGSizeMake(label2.frame.size.width, FLT_MAX) lineBreakMode:UILineBreakModeWordWrap ];
    label2.frame =   CGRectMake(label2.frame.origin.x,label1.frame.origin.y+label1.frame.size.height+10,label2.frame.size.width,size.height);
    
    size = [label3.text sizeWithFont:label3.font constrainedToSize:CGSizeMake(label3.frame.size.width, FLT_MAX) lineBreakMode:UILineBreakModeWordWrap ];
    label3.frame =   CGRectMake(label3.frame.origin.x,label2.frame.origin.y+label2.frame.size.height+10,label3.frame.size.width,size.height);
    

    and finaly you can adjust the content height of your scroll view according tho last label.

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

Sidebar

Related Questions

Possible Duplicate: Can a JavaScript object have a prototype chain, but also be a
Possible Duplicate: How can I increment a date by one day in Java? I
Possible Duplicate: How can I split an IEnumerable<String> into groups of IEnumerable<string> I have
Possible Duplicate: Can’t operator == be applied to generic types in C#? I've got
Possible Duplicate: Can’t operator == be applied to generic types in C#? I've coded
Possible Duplicate: How can I use a carriage return in a HTML tooltip? I'd
Possible Duplicate: How can I convert my java program to an .exe file ?
Possible Duplicate: How can I pre-set arguments in JavaScript function call? (Partial Function Application)
Possible Duplicate: How can I find the method that called the current method? I
Possible Duplicate: .NET windows application, can it be compressed into a single .exe? To

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.