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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:49:03+00:00 2026-06-17T05:49:03+00:00

I have a programmatically created UIScrollView, and I am creating it as the size

  • 0

I have a programmatically created UIScrollView, and I am creating it as the size of the UIView behind it. In viewDidAppear I basically have:

UIScrollView *scrollView= [[UIScrollView alloc] initWithFrame:mainView.bounds];
//mainView being the UIView behind

When the device rotates, naturally the UIView in the background changes bounds to wider and shorter(though x,y ≠ y,x).

In my -(void)didRotateFromInterfaceOrientation: I put `NSLog(@”%@”, NSStringFromCGRect(mainView.bounds));, and the mainView’s bounds has switched, but if I do this:

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
    scrollView.bounds = mainView.bounds;
    NSLog(@"%@", NSStringFromCGRect(scrollView.bounds));
    NSLog(@"%@", NSStringFromCGRect(mainView.bounds));
}

It still shows up wrong..
The NSLog logs out the same bounds for both views, but on screen the mainView is correct, and the scrollView seems flipped or something, as if (0,0) in origin is outside the mainView, and the sizes are flipped wrong..
Do I have to redraw something, or am I calling all of this in the wrong place? Or isn’t .bounds the right variable to use?

EDIT

I realize that updating the frame is different than re-initiating it with initWithFrame:, but I want the current content to stay the same, in the same way..

  • 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-17T05:49:04+00:00Added an answer on June 17, 2026 at 5:49 am

    You need to set the scrollview’s frame not it’s bounds

    scrollView.frame = mainView.bounds;
    

    Or better yet if you set up the correct autoresizing masks/constraints it will resize automatically.

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

Sidebar

Related Questions

I have a UIView that's programmatically being created: - (id)initWithFrame:(CGRect)frame { self = [super
I have a UIScrollView , created programmatically, inside of a UIView . What do
I have a UIScrollView and a UIImageView which I have created programmatically without interface
I have a UITextView which I have created programmatically in the following code: NSLog(@creating
I have a custom UIview which is created programmatically. How to associate to it
I have created a UIImageView in my code: UIImageView *background = [[UIImageView alloc]initWithFrame:CGRectMake(150, 60,
I have my ipad code created programmatically not using nib.I converted my ipad app
I have a custom tableview cell created programmatically that consists of: a background view
HI, I am new to iphone development.I have created the tabbar programmatically and sets
I have a tab bar controller that I have created programmatically, named TPastJourneyTabbar .

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.