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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:26:34+00:00 2026-05-30T18:26:34+00:00

When I start my ViewController in landscape mode (After viewDidLoad is called), I print

  • 0

When I start my ViewController in landscape mode (After viewDidLoad is called), I print the frame it’s giving me the frame size for portrait mode instead.

Is this a bug any suggestions?

- (void)viewDidLoad
{
   [super viewDidLoad];

   NSLog(@"%@", NSStringFromCGRect(self.view.frame));
   // Result is (0, 0 , 768, 1024)
}
  • 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-30T18:26:35+00:00Added an answer on May 30, 2026 at 6:26 pm

    There are a couple of things that you don’t understand.

    First, the system sends you viewDidLoad immediately after loading your nib. It hasn’t even added the view to the view hierarchy yet. So it hasn’t resized your view based on the device’s rotation either.

    Second, a view’s frame is in its superview’s coordinate space. If this is your root view, its superview will be the UIWindow (once the system actually adds your view to the view hierarchy). The UIWindow handles rotation by setting the transform of its subview. This mean that the view’s frame will not necessarily be what you expect.

    Here’s the view hierarchy in portrait orientation:

    (lldb) po [[UIApp keyWindow] recursiveDescription]
    (id) $1 = 0x09532dc0 <UIWindow: 0x9632900; frame = (0 0; 768 1024); layer = <UIWindowLayer: 0x96329f0>>
       | <UIView: 0x9634ee0; frame = (0 20; 768 1004); autoresize = W+H; layer = <CALayer: 0x9633b50>>
    

    and here’s the view hierarchy in landscape-left orientation:

    (lldb) po [[UIApp keyWindow] recursiveDescription]
    (id) $2 = 0x09635e70 <UIWindow: 0x9632900; frame = (0 0; 768 1024); layer = <UIWindowLayer: 0x96329f0>>
       | <UIView: 0x9634ee0; frame = (20 0; 748 1024); transform = [0, -1, 1, 0, 0, 0]; autoresize = W+H; layer = <CALayer: 0x9633b50>>
    

    Notice that in landscape orientation, the frame size is 748 x 1024, not 1024 x 748.

    What you probably want to look at, if this is your root view, is the view’s bounds:

    (lldb) p (CGRect)[0x9634ee0 bounds]
    (CGRect) $3 = {
      (CGPoint) origin = {
        (CGFloat) x = 0
        (CGFloat) y = 0
      }
      (CGSize) size = {
        (CGFloat) width = 1024
        (CGFloat) height = 748
      }
    }
    

    Presumably you want to know when the view’s transform, frame, and bounds get updated. If the interface is in a landscape orientation when your view controller loads its view, you will receive messages in this order:

    {{0, 0}, {768, 1004}} viewDidLoad
    {{0, 0}, {768, 1004}} shouldAutorotateToInterfaceOrientation:
    {{0, 0}, {768, 1004}} shouldAutorotateToInterfaceOrientation:
    {{0, 0}, {768, 1004}} viewWillAppear:
    {{0, 0}, {768, 1004}} shouldAutorotateToInterfaceOrientation:
    {{0, 0}, {768, 1004}} shouldAutorotateToInterfaceOrientation:
    {{0, 0}, {768, 1004}} willRotateToInterfaceOrientation:duration:
    {{0, 0}, {1024, 748}} viewWillLayoutSubviews
    {{0, 0}, {1024, 748}} layoutSubviews
    {{0, 0}, {1024, 748}} viewDidLayoutSubviews
    {{0, 0}, {1024, 748}} willAnimateRotationToInterfaceOrientation:duration:
    {{0, 0}, {1024, 748}} shouldAutorotateToInterfaceOrientation:
    {{0, 0}, {1024, 748}} viewDidAppear:
    

    You can see that your view’s bounds change after you receive willRotateToInterfaceOrientation:duration: and before you receive viewWillLayoutSubviews.

    The viewWillLayoutSubviews and viewDidLayoutSubviews methods are new to iOS 5.0.

    The layoutSubviews message is sent to the view, not the view controller, so you will need to create a custom UIView subclass if you want to use it.

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

Sidebar

Related Questions

What init metod is called everytime a viewcontroller is pushed to window? -viewDidLoad and
/* I start with this: */ <Report> <prop1>4</prop1> <prop2>2255</prop2> <prop3>true</prop3> <prop4>false</prop4> <prop5>true</prop5> </Report> /*
I'm subclassing UIScrollView and on the start I fill this ShowsScrollView with some items.
I'm trying to only support landscape. There's a new requirement to show this dialog
I am using this http://imthi.com/blog/programming/iphone-rss-reader-application-with-source-code.php as a start for my rss reader in my
Probably a simple question, but: My app starts (and is mostly) in portrait mode,
I start off with a login screen. Then after the user logs in I
I have a problem with the methoed ViewDidLoad... At the start, my application must
Ok hopefully this is an easy question: I have a main viewcontroller that is
I'm trying to start a different ViewController when a BOOL in NSUserDefaults isn't set..

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.