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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:22:59+00:00 2026-06-08T18:22:59+00:00

my App has several uiViews and set to support both orientations. since my uiViews

  • 0

my App has several uiViews and set to support both orientations. since my uiViews frames are only part of the whole size of the iPad, so I’m trying to center my uiviews frame depending on how the iPad is held aka orientation. It’s is done in this manner in the view controller.m file:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    UIInterfaceOrientation des=self.interfaceOrientation;

    if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad) //iPad
    {
        CGRect ScreenBounds  = [[UIScreen mainScreen] bounds];

        if(des==UIInterfaceOrientationPortrait||des==UIInterfaceOrientationPortraitUpsideDown)//ipad-portrait
        {

            ipStPosX=(ScreenBounds.size.width -360)/2;
            ipStPosY=100; 
            return YES;
        }
        else//ipad -landscape
        {
            ipStPosX=(ScreenBounds.size.height -360)/2;
            ipStPosY=100; 
            return YES;
        }
    }
    else//iphone
    {
        UIInterfaceOrientation des=self.interfaceOrientation;

        if(des==UIInterfaceOrientationPortrait||des==UIInterfaceOrientationPortraitUpsideDown) //iphone portrait
        {
            return NO;
        }
        else //iphone -landscape
        {
            return YES;
        }
    }
}

after launching the app and changing the orientation it will always go to the portrait part, UIInterfaceOrientationPortrait, regardless of how i hold the device.

I saw some old posts that didn’t really fit the issue and were confusing or dated so any help here will be great.

  • 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-08T18:23:00+00:00Added an answer on June 8, 2026 at 6:23 pm

    shouldAutorotateToInterfaceOrientation: is for simply telling iOS that you support particular orientations. since you want everything but iPhone landscape, you should return

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation {
        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) //iPad
            return YES;
        return UIInterfaceOrientationIsPortrait(orientation);
    }
    

    for actually adjusting what you display, you want to use willRotateToInterfaceOrientation:duration: or didRotateFromInterfaceOrientation: for actually changing items. in your case, given that you are just adjusting some iVars depending upon which orientation you are in, i presume you will use the latter.

    - (void)didRotateToInterfaceOrientation:(UIInterfaceOrientation)fromOrientation
        UIInterfaceOrientation des = self.interfaceOrientation;
        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) //iPad
        {
            CGRect ScreenBounds  = [[UIScreen mainScreen] bounds];
    
            if (UIInterfaceOrientationIsPortrait(des))//ipad-portrait
            {
                ipStPosX=(ScreenBounds.size.width -360)/2;
                ipStPosY=100; 
            }
            else //ipad -landscape
            {
                ipStPosX=(ScreenBounds.size.height -360)/2;
                ipStPosY=100; 
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a winforms app and the main (and only) form has several buttons.
My app has several buttons which trigger different events. The user should NOT be
Ive got a jquery app that has several grids (jqgrid) in defferent tabs. Below
I'm working on a PHP app that has several objects that can be commented
I have a folder in my WPF app Images that has several .png files
I have a document-based Core Data app. My main Core Data entity has several
The app has an Action Bar, the action bar has several navigation tabs on
I'm building an app that has several different sections to it, all of which
I'm a newb iPhone developer writing an app that has several large JPGs and
I have a view based app. Its self.view has several subviews and shouldAutorotateToInterfaceOrientation is

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.