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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:25:36+00:00 2026-05-19T17:25:36+00:00

I have spent the last several hours trying to get this to work and

  • 0

I have spent the last several hours trying to get this to work and I can’t so I need to know if what I am trying to do is the correct thing. Its driving me mad!

My goal is to have a ViewController that detects orientation change. When it’s portrait it shows a view with a UITableView, when its landscape it shows a UIView with content that I will programmatically create.

In my parent viewcontroller I have:

- (void)viewDidLoad 
{
    [super viewDidLoad];

TableDataViewController *tableDataController = [[TableDataViewController alloc]  
          initWithNibName:@"TableDataViewController"                                                                                
                   bundle:nil];
self.tableDataViewController = tableDataController;
[self.view insertSubview: tableDataController.view atIndex:0];
[tableDataController release];
}

This loads my view containing the table view and the controller that goes with it. The user then rotates the device and the function:

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toOrientation                                                 
duration:(NSTimeInterval)duration
{
if (toOrientation == UIInterfaceOrientationPortrait) {
    NSLog(@"PerformAnalysisViewController: Gone to Potrait");   
} 

if ((toOrientation == UIInterfaceOrientationLandscapeLeft) || 
    (toOrientation == UIInterfaceOrientationLandscapeRight)) {
    NSLog(@"PerformAnalysisViewController: Gone to Landscape");

           // Load new view here
           CGRect frame = [[UIScreen mainScreen] applicationFrame];
       UIView *horizView = [[[HorizView alloc]
                  initWithFrame:frame] autorelease];
       [self setView:horizView];;   
}
}

will trigger depending. However it doesn’t trigger? Is this because control has passed to the Subview I have inserted in the viewDidLoad? If so how do I get it back? Do I have to get it to detect orientation and then remove itself from the superview?

If that was then working would the new view be added as I have it above? I have tried reading the Apple documentation but I can’t make this work.

All help greatly appreciated.

Mike

  • 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-19T17:25:36+00:00Added an answer on May 19, 2026 at 5:25 pm

    I am using the willRotateToInterfaceOrientation method in order to handle UI rotation:

    - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration {
       if( interfaceOrientation == UIInterfaceOrientationPortrait || 
           interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown ) {
          self.backgroundImageView.image = [UIImage imageNamed:@"vertical.png"];
       }
       else {
          self.backgroundImageView.image = [UIImage imageNamed:@"horizontal.png"];
       }
    
    }
    

    Please check, that your Info.plist supports more than one orientation and that you have implemented shouldAutorotateToInterfaceOrientation:interfaceOrientation by returning YES.

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

Sidebar

Related Questions

I have spent the last 3 hours trying to get this code working. I
I have spent the last several hours trying to simply post the data (text/html)
Urgh, I have spent the last couple of hours on this now. I normally
This afternoon I spent several hours trying to find a bug in my custom
I've spent several hours over the past few days trying to get PostgreSQL to
I have spent the last several hours scouring the internet looking for examples and
I have spent last few hours trying to understand why my javascript timer is
I've spent the last three hours trying to get a simple Twitter status update
I hope someone can help me as I've already spent several hours trying to
I have spent the last several years fighting tooth and nail to avoid working

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.