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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:35:03+00:00 2026-05-28T13:35:03+00:00

I’m resizing a UIView and a UIScrollView based on the number of pixels that

  • 0

I’m resizing a UIView and a UIScrollView based on the number of pixels that UITextViews are being moved. I have all of the pixels being stored in int variables. At the end of my method to populate all of these text views I’m using this:

viewHeight += viewPixelsToBeAdded;
viewHeight -= viewPixelsToBeRemoved;
detailsView.frame = CGRectMake(0, 20, 320, viewHeight);
realDetailsView.frame = CGRectMake(0, 20, 320, viewHeight);

viewHeight is the constant view height which is 1475. I’m using viewPixelsToBeAdded and viewPixelsToBeRemoved to hold the total number of pixels that the view needs to be resized. When I use the above code… my scrollView (detailsView) just stops scrolling. Altogether. I have my objects inside of a view. That view is inside of a scrollView. Is there an easier way to go about resizing this stuff? Why does my scrollView stop scrolling when I increase or decrease its height? Any help would be greatly appreciated. I can post the entire populateLabels method if need be. I kinda feel like I’m taking the long route with it anyway.

-(void) populateLabels {

NSString *noInfo = (@"No Information Available");
lblCgName.text = _Campground.campground;
NSString *cgLoc = _Campground.street1; 
NSString *cgCity = _Campground.city;
NSString *cgState = _Campground.state1;
NSString *cgCountry = _Campground.country;
NSString *cgZipPostal = _Campground.zipPostal;
cgLoc = [[cgLoc stringByAppendingString:@", "] stringByAppendingString:cgCity];
cgLoc = [[cgLoc stringByAppendingString:@", "] stringByAppendingString:cgState];
cgLoc = [[cgLoc stringByAppendingString:@", "] stringByAppendingString:cgCountry];
cgLoc = [[cgLoc stringByAppendingString:@" "] stringByAppendingString:cgZipPostal];
lblCgLoc.text = cgLoc;
double dRate = [_Campground.regRate1 doubleValue];
double dRate2 = [_Campground.regRate2 doubleValue];
NSString *rate = [[NSString alloc] initWithFormat:@"$%0.2f",dRate];
NSString *rate2 = [[NSString alloc] initWithFormat:@"$%0.2f",dRate2];
if ([rate2 isEqualToString:@"$0.00"]) {
    lblRate.text = rate;
} else {
    rate = [[rate stringByAppendingString:@" - "] stringByAppendingString:rate2];
    lblRate.text = rate;
}
double dPaRate = [_Campground.paRate1 doubleValue];
double dPaRate2 = [_Campground.paRate2 doubleValue];
NSString *paRate = [[NSString alloc] initWithFormat:@"$%0.2f",dPaRate];
NSString *paRate2 = [[NSString alloc] initWithFormat:@"$%0.2f",dPaRate2];
if ([paRate2 isEqualToString:@"$0.00"]) {
    lblPaRate.text = paRate;
} else {
    paRate = [[paRate stringByAppendingString:@" - "] stringByAppendingString:paRate2];
    lblPaRate.text = paRate;
}
lblLocal1.text = _Campground.localPhone1;
lblLocal2.text = _Campground.localPhone2;
lblTollFree.text = _Campground.tollFree;
lblFax.text = _Campground.fax;
lblEmail.text = _Campground.email;
lblWebsite.text = _Campground.website;
NSString *gps = _Campground.latitude;
NSString *longitude = _Campground.longitude;
gps = [[gps stringByAppendingString:@", "] stringByAppendingString:longitude];
lblGps.text = gps;

int viewHeight = 1475;
int textViewDefaultHeight = 128;
int newTextViewHeight = 0;
int highlightsPixelsRemoved = 0;
int highlightsPixelsAdded = 0;
int notesPixelsRemoved = 0;
int notesPixelsAdded = 0;
int directionsPixelsRemoved = 0;
int directionsPixelsAdded = 0;
int rentalsPixelsRemoved = 0;
int rentalsPixelsAdded = 0;
int viewPixelsToBeRemoved = 0;
int viewPixelsToBeAdded = 0;

//----------------------------------------------------------------------------    

txtHighlights.text = _Campground.highlights;
[self fitFrameToContent:txtHighlights];
newTextViewHeight = txtHighlights.contentSize.height;
if (newTextViewHeight > textViewDefaultHeight) {
    highlightsPixelsAdded = newTextViewHeight - textViewDefaultHeight;
    viewPixelsToBeAdded += highlightsPixelsAdded;
    txtTentsHead.frame = CGRectOffset(txtTentsHead.frame, 0, highlightsPixelsAdded);
    txtTents.frame = CGRectOffset(txtTents.frame, 0, highlightsPixelsAdded);
    txtNotesHead.frame = CGRectOffset(txtNotesHead.frame, 0, highlightsPixelsAdded);
    txtNotes.frame = CGRectOffset(txtNotes.frame, 0, highlightsPixelsAdded);
    txtDirectionsHead.frame = CGRectOffset(txtDirectionsHead.frame, 0, highlightsPixelsAdded);
    txtDirections.frame = CGRectOffset(txtDirections.frame, 0, highlightsPixelsAdded);
    txtRentalsHead.frame = CGRectOffset(txtRentalsHead.frame, 0, highlightsPixelsAdded);
    txtRentals.frame = CGRectOffset(txtRentals.frame, 0, highlightsPixelsAdded);


} else if (newTextViewHeight < textViewDefaultHeight) {
    highlightsPixelsRemoved = textViewDefaultHeight - newTextViewHeight;
    viewPixelsToBeRemoved += highlightsPixelsRemoved;
    txtTentsHead.frame = CGRectOffset(txtTentsHead.frame, 0, -highlightsPixelsRemoved);
    txtTents.frame = CGRectOffset(txtTents.frame, 0, -highlightsPixelsRemoved);
    txtNotesHead.frame = CGRectOffset(txtNotesHead.frame, 0, -highlightsPixelsRemoved);
    txtNotes.frame = CGRectOffset(txtNotes.frame, 0, -highlightsPixelsRemoved);
    txtDirectionsHead.frame = CGRectOffset(txtDirectionsHead.frame, 0, -highlightsPixelsRemoved);
    txtDirections.frame = CGRectOffset(txtDirections.frame, 0, -highlightsPixelsRemoved);
    txtRentalsHead.frame = CGRectOffset(txtRentalsHead.frame, 0, -highlightsPixelsRemoved);
    txtRentals.frame = CGRectOffset(txtRentals.frame, 0, -highlightsPixelsRemoved);

}   


//----------------------------------------------------------------------------    

txtTents.text = _Campground.tents;

//----------------------------------------------------------------------------    

txtNotes.text = _Campground.notes;
[self fitFrameToContent:txtNotes];
newTextViewHeight = txtNotes.contentSize.height;
if (newTextViewHeight > textViewDefaultHeight) {
    notesPixelsAdded = newTextViewHeight - textViewDefaultHeight;
    viewPixelsToBeAdded += notesPixelsAdded;

    txtDirectionsHead.frame = CGRectOffset(txtDirectionsHead.frame, 0, notesPixelsAdded);
    txtDirections.frame = CGRectOffset(txtDirections.frame, 0, notesPixelsAdded);
    txtRentalsHead.frame = CGRectOffset(txtRentalsHead.frame, 0, notesPixelsAdded);
    txtRentals.frame = CGRectOffset(txtRentals.frame, 0, notesPixelsAdded);


} else if (newTextViewHeight < textViewDefaultHeight) {
    notesPixelsRemoved = textViewDefaultHeight - newTextViewHeight;
    viewPixelsToBeRemoved += notesPixelsRemoved;

    txtDirectionsHead.frame = CGRectOffset(txtDirectionsHead.frame, 0, -notesPixelsRemoved);
    txtDirections.frame = CGRectOffset(txtDirections.frame, 0, -notesPixelsRemoved);
    txtRentalsHead.frame = CGRectOffset(txtRentalsHead.frame, 0, -notesPixelsRemoved);
    txtRentals.frame = CGRectOffset(txtRentals.frame, 0, -notesPixelsRemoved);

}   


//----------------------------------------------------------------------------    

txtDirections.text = _Campground.directions;
[self fitFrameToContent:txtDirections];
newTextViewHeight = txtDirections.contentSize.height;
if (newTextViewHeight > textViewDefaultHeight) {
    directionsPixelsAdded = newTextViewHeight - textViewDefaultHeight;
    viewPixelsToBeAdded += directionsPixelsAdded;

    txtRentalsHead.frame = CGRectOffset(txtRentalsHead.frame, 0, directionsPixelsAdded);
    txtRentals.frame = CGRectOffset(txtRentals.frame, 0, directionsPixelsAdded);


} else if (newTextViewHeight < textViewDefaultHeight) {
    directionsPixelsRemoved = textViewDefaultHeight - newTextViewHeight;
    viewPixelsToBeRemoved += directionsPixelsRemoved;

    txtRentalsHead.frame = CGRectOffset(txtRentalsHead.frame, 0, -directionsPixelsRemoved);
    txtRentals.frame = CGRectOffset(txtRentals.frame, 0, -directionsPixelsRemoved);

} 

//----------------------------------------------------------------------------    

txtRentals.text = _Campground.rentals;
[self fitFrameToContent:txtRentals];
newTextViewHeight = txtRentals.contentSize.height;
if (newTextViewHeight > textViewDefaultHeight) {
    rentalsPixelsAdded = newTextViewHeight - textViewDefaultHeight;
    viewPixelsToBeAdded += rentalsPixelsAdded;


} else if (newTextViewHeight < textViewDefaultHeight) {
    rentalsPixelsRemoved = textViewDefaultHeight - newTextViewHeight;
    viewPixelsToBeRemoved += rentalsPixelsRemoved;

} 

viewHeight += viewPixelsToBeAdded;
viewHeight -= viewPixelsToBeRemoved;
detailsView.frame = CGRectMake(0, 20, 320, viewHeight);
scrollView.frame = CGRectMake(0, 20, 320, viewHeight);
}
  • 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-28T13:35:04+00:00Added an answer on May 28, 2026 at 1:35 pm

    A scrollView has two sizes: Its frame, which determines how large (and where) it is on the screen, and its contentSize, which determines how far it will scroll.

    If contentSize is the same or smaller than frame.size, the scrollView will not scroll (because there is nothing to scroll to).

    Usually, you’ll want to set the contentSize of a scrollView to the size of the view(s) that you put into it.

    Say you have a UIImageView that has a size of 1000×1000 points. Its frame will probably by CGRectMake(0, 0, 1000, 1000). Say your ScrollView is a fullscreen on an iPhone in portrait orientation, so it has a frame of CGRectMake(0, 0, 320, 480). If you now set its contentSize to CGSizeMake(1000, 1000), it will be able to scroll over all of the picture. If you make the contentSize a rectangle of 320 x 480, it won’t scroll at all. And if you set the contentSize to 2000×2000, you will be able to scroll further than the picture.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I have a bunch of posts stored in text files formatted in yaml/textile (from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,

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.