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

  • Home
  • SEARCH
  • 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 580511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:28:51+00:00 2026-05-13T14:28:51+00:00

I have set up an application and used some of the basic code from

  • 0

I have set up an application and used some of the basic code from “The iPhone Developer’s Cookbook” to create a simple view. The application works correctly in portrait mode, but when it is rotated, the dimensions of the boxes stay the same. Here is my code:

- (void)loadView {
    //Create the full application frame (minus the status bar) - 768, 1004
    CGRect fullRect = [[UIScreen mainScreen] applicationFrame]; 

    //Create the frame of the view ie fullRect-(tabBar(49)+navBar(44)) - 768, 911
    CGRect viewRect = CGRectMake(0, 64, fullRect.size.width, fullRect.size.height-93.0);

    //create the content view to the size
    contentView = [[UIView alloc] initWithFrame:viewRect]; 
    contentView.backgroundColor = [UIColor whiteColor];

    // Provide support for autorotation and resizing 
    contentView.autoresizesSubviews = YES;
    contentView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);

    self.view = contentView; 
    [contentView release];

    // reset the origin point for subviews. The new origin is 0,0 
    viewRect.origin = CGPointMake(0.0f, 0.0f);

    // Add the subviews, each stepped by 32 pixels on each side 
    UIView *subview = [[UIView alloc] initWithFrame:CGRectInset(viewRect, 32.0f, 32.0f)]; 
    subview.backgroundColor = [UIColor lightGrayColor]; 
    [contentView addSubview:subview]; 
    [subview release];

    subview = [[UIView alloc] initWithFrame:CGRectInset(viewRect, 64.0f, 64.0f)]; 
    subview.backgroundColor = [UIColor darkGrayColor]; 
    [contentView addSubview:subview]; 
    [subview release];

    subview = [[UIView alloc] initWithFrame:CGRectInset(viewRect, 96.0f, 96.0f)]; 
    subview.backgroundColor = [UIColor blackColor]; 
    [contentView addSubview:subview]; 
    [subview release];
}

Is there any way to have this reload with the new dimensions when it is rotated or a better way of accommodating the orientation change?

Thanks
JP

  • 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-13T14:28:52+00:00Added an answer on May 13, 2026 at 2:28 pm

    I may be misunderstanding your problem. By “boxes”, do you mean the subviews?

    If so, the subviews will retain their apparent dimensions when rotated because they are squares.

    In any case, viewDidLoad is only called when a view is first initialized, usually from a nib. If you need to make changes to a view when it rotates, you need to make the changes in willRotateToInterfaceOrientation:duration: and/or didRotateFromInterfaceOrientation:.

    To change the dimensions of any view, simply reset its frame.

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

Sidebar

Related Questions

We have a Java web application and we'd like to set up some basic
I have a named scope set up in my rails application that is used
I have a web application that has one set of files used by 50+
In my c# application i have this small form which is used to set
We have a function used within our PHP/MySQL application which returns basic configuration information,
I have set in my mastersite of my asp.net application the following that the
I have set adapter to the MultiAutoCompleteTextView in my android application. ArrayAdapter<String> adapter =
I have to implement an application in which I have set small edittext for
I have set up an app that is registered for remote notifications. - (void)application:(UIApplication*)application
I have a sample Rails 3.1.1 application that I have set devise up 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.