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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:18:10+00:00 2026-05-23T10:18:10+00:00

I am currently creating an iPhone app using Xcode 4.0.2, I want the app

  • 0

I am currently creating an iPhone app using Xcode 4.0.2, I want the app to switch views when the user turns their phone. For example: If a user turns their iPhone on it’s side, the iPhone would change to a pre-made landscape view. I have created the code for it, but when I run it in iOS Simulator and rotate the device nothing happens. What am I doing wrong?

Header File:

#import "FlipsideViewController.h"

@interface MainViewController : UIViewController <FlipsideViewControllerDelegate> {
IBOutlet UIView *portraitView;
IBOutlet UIView *landscapeView;

}
@property (nonatomic, retain) UIView *portraitView;

@property (nonatomic, retain) UIView *landscapeView;

@end

Implementation File (.m):

#import "MainViewController.h"
#define deg2rad (3.1415926/180.0)

@implementation MainViewController
@synthesize portraitView;
@synthesize landscapeView;

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationPortrait);
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {

if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
    self.view=landscapeView;
    self.view.transform=CGAffineTransformMakeRotation(deg2rad*(90));
    self.view.bounds=CGRectMake(0.0, 0.0, 480.0, 320.0);
} else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
    self.view=landscapeView;
    self.view.transform=CGAffineTransformMakeRotation(deg2rad*(-90));
    self.view.bounds=CGRectMake(0.0, 0.0, 480.0, 320.0);
} else {
    self.view=portraitView;
    self.view.transform=CGAffineTransformMakeRotation(deg2rad*(0));
    self.view.bounds=CGRectMake(0.0, 0.0, 300.0, 460.0);
}

[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];

}

@end

I have taken out some things that are not necessary, so the .m file may look a little bit bare. I have linked the IBOutlets landscapeView and portraitView to 2 different views within one .xib file called MainViewController.xib

When I build it, there are no errors, warnings, or signals.

Is there an easier way to do this or am I just doing it wrong? Could somebody help?
Thanks in advance!

  • 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-23T10:18:10+00:00Added an answer on May 23, 2026 at 10:18 am

    You need to fix your shouldAutorotateToInterfaceOrientation for one. The return value will always match up with the first, it should look more like

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
    // Return YES for supported orientations.
        return (interfaceOrientation == UIInterfaceOrientationPortrait)
            || (interfaceOrientation == UIInterfaceOrientationLandscapeLeft)
            ||(interfaceOrientation == UIInterfaceOrientationLandscapeRight);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating an iphone app and wanted to know if using NIB files
I am creating my second iPhone app, and I've included a feedback form using
I'm currently creating an iPhone app and we need some testing with about 20~30
I am creating an iphone app within XCODE the makes use of an SQLite3
I am currently creating an e-commerce site using C# ASP.NET MVC and have just
I'm currently in the midst of creating an app that requires a very nifty
I'm using Jqtouch to design a iphone app. As I'm using a standard header/toolbar
The iphone app I am creating has an array of commonly used settings. These
I'm currently creating an iPhone web application for piano chords, and I wanted to
I am creating an app which has version for both iPhone and iPad, iPad

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.