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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:34:24+00:00 2026-05-27T16:34:24+00:00

Using Xcode 4.2.1 iPad iOS 5.0.1, create a new Single View iPad project. In

  • 0

Using Xcode 4.2.1 iPad iOS 5.0.1, create a new “Single View” iPad project. In the controller, add:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}

- (void) dumpView: (UIView *) view {
    CGRect frame = view.frame ;
    CGRect bounds = view.bounds ;
    CGPoint center = view.center ;

    NSLog(@"view [%@]:%d frame=%@ bounds=%@ center=%@"
          ,   NSStringFromClass(view.class)
          ,   [view hash]
          ,   NSStringFromCGRect(frame)
          ,   NSStringFromCGRect(bounds)
          ,   NSStringFromCGPoint(center)) ;
}

- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation) fromInterfaceOrientation {

    NSLog(@"INViewController.didRotateFromInterfaceOrientation: %d to %d", fromInterfaceOrientation, self.interfaceOrientation) ;
    [self dumpView: self.view] ;
    [self dumpView: self.view.superview] ;
}

Run it, rotate the device and you will get:

INViewController.didRotateFromInterfaceOrientation: 2 to 4
view [UIView]   bounds={{0, 0}, {1024, 748}} center={394, 512}
view [UIWindow] bounds={{0, 0}, {768, 1024}} center={384, 512}

In other words, the UIView has its coordinates “swapped to landscape” as expected, but its parent UIWindow still claims to be in portrait mode…

Also, the UIView size seems to be slightly wrong: the y coordinate which should be at 20 is at 0 …

Anyone knows what this means?

  • 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-27T16:34:25+00:00Added an answer on May 27, 2026 at 4:34 pm

    The UIWindow’s coordinate system is always in portrait orientation. It applies the rotation by setting its rootViewController’s view’s transform. For example, I created a test app using the single-view template and ran it. In portrait orientation:

    (gdb) po [[(id)UIApp keyWindow] recursiveDescription]
    <UIWindow: 0x9626a90; frame = (0 0; 768 1024); layer = <UIWindowLayer: 0x9626b80>>
       | <UIView: 0x96290e0; frame = (0 20; 768 1004); autoresize = W+H; layer = <CALayer: 0x96286a0>>
    

    After rotating left:

    (gdb) po [[(id)UIApp keyWindow] recursiveDescription]
    <UIWindow: 0x9626a90; frame = (0 0; 768 1024); layer = <UIWindowLayer: 0x9626b80>>
       | <UIView: 0x96290e0; frame = (0 0; 748 1024); transform = [0, 1, -1, 0, 0, 0]; autoresize = W+H; layer = <CALayer: 0x96286a0>>
    

    After rotating right:

    (gdb) po [[(id)UIApp keyWindow] recursiveDescription]
    <UIWindow: 0x9626a90; frame = (0 0; 768 1024); layer = <UIWindowLayer: 0x9626b80>>
       | <UIView: 0x96290e0; frame = (20 0; 748 1024); transform = [0, -1, 1, 0, 0, 0]; autoresize = W+H; layer = <CALayer: 0x96286a0>>
    

    Notice how the transform is set (to a 90-degree rotation matrix) when the device is rotated.

    Regarding your question about the UIView size: a view’s bounds are in its own coordinate space, and by default a view’s bounds’ origin is at the origin (0,0) of its coordinate space. A view’s frame is in its parent’s coordinate space. You can see the 20 you were expecting in the recursive descriptions above, or by printing the frame directly:

    (gdb) p (CGRect)[[[[(id)UIApp keyWindow] subviews] lastObject] frame]
    $2 = {
      origin = {
        x = 0, 
        y = 20
      }, 
      size = {
        width = 768, 
        height = 1004
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a iPad 2 device with iOS version 5.0.1. I'm using Xcode 4.2
Using Xcode 4.x I created a SplitView project for iPad From RootViewController I'm trying
when i create a cocos2d projecyt, XCode menu item Project\Upgrade Current Target for iPad
I created an empty Single View application using Xcode 4.2 on OSX Lion 10.7.2
I have created an iPad app, using UIPageviewController in Xcode 4.2 (iOS 5). Now,
I'm using xcode and I was wondering if there was a way to view
I'm new to development using Xcode, and am having trouble using the built-in Leaks
I have two cocoa-touch apps in one Xcode project. Xcode gives me iPhone/iPad related
I am totally new to making ipad/iphone application. I am totally new to using
I've created an iPad game using the Universal App Xcode template. Since I'm in

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.