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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:02:57+00:00 2026-05-25T14:02:57+00:00

In my project I am required to implement the orientation feature of iPhone. For

  • 0

In my project I am required to implement the orientation feature of iPhone. For this I have created two xib files and one UIViewController controller file, one for landscape and other for portrait. I have taken one UIViewController because the content of the xib files are same.

Now I want to load the respective xib file depending on the rotation and the content should remain populated in the TextField when the specific file loads. How should I implement this?

CODE:

if( orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight) 
{
   NSArray *nibArray = [[NSBundle mainBundle] loadNibNamed:@"landscapeView" owner:self options:nil]; UIView *viewItem = (UIView *)[nibArray objectAtIndex:0]; self.view = viewItem;
}
else if(orientation == UIDeviceOrientationPortrait || orientation == UIDeviceOrientationPortraitUpsideDown) 
{
   //same above lines only different nib name 
}
  • 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-25T14:02:59+00:00Added an answer on May 25, 2026 at 2:02 pm

    You can check in your init method of UIViewController device orientation using following code

    if (UIDeviceOrientationIsLandscape([[UIDevice currentDevice] orientation])
    {
         // load view for landscape mode
    }else
    {
         // load view for portrait mode
    }
    

    And choose .xib file that correspond to current orientation.

    Hope, this will work.

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

Sidebar

Related Questions

I have to start a new project where user authentication/management will be required. A
I have created a project in NetBeans by downloading some third party jars of
I'm programming an ASP.NET MVC3 project, and I am required to implement user authentication
In my project I have a controller that allows you to create multiple letters
I have model validation in my ASP.NET MVC2 project, and I want to implement
I'm writing a project for a basic OOP C++ course. I have to implement
During one of my project i need to add required field validation on the
I have a a number of UIViewControllers in my project that implement the UITableViewDataSource
I'm working on a project that will require me to implement a calendar. I'm
I am required to work on a php project that requires the database to

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.