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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:06:04+00:00 2026-05-29T08:06:04+00:00

I think this has probably been asked, but after reading a lot, I’m not

  • 0

I think this has probably been asked, but after reading a lot, I’m not sure I have found an answer.

When the app is rotated to landscape, I’m adding a new view to the main view. The new view is constructed and added in code like this:

UIView * newView = ....
[rootView addSubview:newView];

But because the simulator is rotated to landscape when I add the new view I get this:

+------------------------------------------------------+
+  +---------------------------------------------+     +
+  |                          |                  |     +
+  |                          |                  |     +
+  |      newView             |   rootView       |     +
+  |      (Landscape          |   (Landscape)    |     +
+  |   but portrait size)     |                  |  () +
+  |                          |                  |     +
+  |                          |                  |     +
+  |                          |                  |     +
+  |                          |                  |     +
+  +---------------------------------------------+     +
+------------------------------------------------------+

So I added newView.bounds = rootView.bounds; newView.center = rootView.center; thinking that would position the newView directly over the top of the rootView, but instead I got this:

+------------------------------------------------------+
+  +---------------------------------------------+     +
+  |                                             |     +
+  |                                             |     +
+  |--------------------------+   rootView       |     +
+  |                          |   (Landscape)    |     +
+  |         newView          |                  |  () +
+  |  (Landscape size,        |                  |     +
+  |   but offset)            |                  |     +
+  |                          |                  |     +
+  |                          |                  |     +
+  +---------------------------------------------+     +
+------------------------------------------------------+

I’m trying to figure out why they are different even though I’ve set the bounds and centers to be the same.

Dumping out the views I get this:

 rootView; frame = (0 0; 768 1024); transform = [0, -1, 1, 0, 0, 0]; autoresize = W+H; layer = <CALayer: 0x98870a0>>
 newView ; frame = (-128 128; 1024 768); autoresize = W+H; layer = <CALayer: 0x6e470a0>>

So it appears that the rootView is still 768w x 1024h, just rotated by a transform, and after setting bounds and centre, the new view is 1024w x 768h and offset by 128 points.

  • 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-29T08:06:05+00:00Added an answer on May 29, 2026 at 8:06 am

    After some more playing around, I came up with this:

     // Position the new view offscreen.
    CGFloat width = rootView.bounds.size.width;
    CGFloat height = rootView.bounds.size.height;
    newView.frame = CGRectMake(0, height, width, height);
    [rootView addSubview:newView];
    
     // Animate to the center of the view.
    [UIView animateWithDuration:1.0 animations:^{
        newView.frame = CGRectMake(0,0, width, height);
     }];
    

    It works, I’m just wondering if there is a better solution.

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

Sidebar

Related Questions

I am sure this has been asked already, but I have been trying all
You're probably thinking this has been asked a million times before but I think
I know this has probably been asked a lot on here, but I am
probably this question has been asked in many forms before but still I think
I know this has probably been asked before, but I can't find it with
I think the title for this question is probably wrong, but I'm not sure
I realise that this question has probably been asked to death, but none of
I think this has been asked a million times, but with different definitions of
This probably has been asked many times before but I was wondering how to
I don't think this question has been asked before. I'm a bit confused on

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.