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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:10:38+00:00 2026-05-31T11:10:38+00:00

in my app I got a Home with several buttons. Each button opens a

  • 0

in my app I got a Home with several buttons. Each button opens a separate view. In each view, if I put the device in landscape a help view is shown. Everything works fine except that in whatever view I am, if I put the iPhone like to lay on a table (I don’t know how to eplain better…) the app exites from that view and comes back to the first view, the Home.
Here’s my code:

- (void)viewDidLoad
{
[super viewDidLoad];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(orientationChanged:)name:@"UIDeviceOrientationDidChangeNotification" 
object:nil];
[self performSelector:@selector (ritardo) withObject:nil afterDelay:5.0f];
}

-(void)orientationChanged:(NSNotification *)object{
UIDeviceOrientation deviceOrientation = [[object object] orientation];

if (deviceOrientation == UIInterfaceOrientationPortrait)
{
    [UIView beginAnimations:@"View Flip" context:nil];
    [UIView setAnimationDuration:0.5f];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
    self.view = self.portraitView;
}
else  if (deviceOrientation == UIInterfaceOrientationLandscapeLeft || deviceOrientation 
== UIInterfaceOrientationLandscapeRight)
{
    [UIView beginAnimations:@"View Flip" context:nil];
    [UIView setAnimationDuration:0.5f];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
    self.view = self.landscapeView;
}
[UIView commitAnimations];
[self dismissModalViewControllerAnimated:NO];
}

-(void) ritardo {
ruota.image = [UIImage imageNamed:@"RuotaPerAiuto.png"];    
}

- (void)viewDidUnload
{
[self setPortraitView:nil]; 
[self setLandscapeView:nil];
[self setRuota:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation: 
(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
    return YES;
}
}
@end

Hi hope you can help me

EDIT:
I modified the -(void)orientationChanged:(NSNotification *)object{ in this way:

-(void)orientationChanged:(NSNotification *)object{
UIDeviceOrientation deviceOrientation = [[object object] orientation];
if (deviceOrientation == UIDeviceOrientationFaceUp)// || deviceOrientation == 
UIDeviceOrientationFaceDown) 
{
    return;
}
if (deviceOrientation == UIInterfaceOrientationPortrait || deviceOrientation == 
UIInterfaceOrientationPortraitUpsideDown)
{
    [UIView beginAnimations:@"View Flip" context:nil];
    [UIView setAnimationDuration:0.5f];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
    self.view = self.portraitView;
}
else 
if (deviceOrientation == UIInterfaceOrientationLandscapeLeft || deviceOrientation == 
UIInterfaceOrientationLandscapeRight)
{
    [UIView beginAnimations:@"View Flip" context:nil];
    [UIView setAnimationDuration:0.5f];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
    self.view = self.landscapeView;
}
[UIView commitAnimations];
[self dismissModalViewControllerAnimated:NO];
}

Now, if I’m in portrait and get the iPhone to faceUp position works good. But when I change position from faceUp to portrait it goes back to the home…

  • 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-31T11:10:39+00:00Added an answer on May 31, 2026 at 11:10 am

    The problem is that UIDeviceOrientationDidChangeNotification will be fired independently from shouldAutorotateToInterfaceOrientation. And you don’t handle the cases UIInterfaceOrientationPortraitUpsideDown, UIDeviceOrientationFaceUp and UIDeviceOrientationFaceDown in the method orientationChanged:. So when the device is rotated to one of these orientations, your code is equivalent to:

    -(void)orientationChanged:(NSNotification *)object
    {
        [UIView commitAnimations];
        [self dismissModalViewControllerAnimated:NO];
    }
    

    So you should remove the lines:

    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:)name:@"UIDeviceOrientationDidChangeNotification" object:nil];
    

    and put you code in the method willRotateToInterfaceOrientation:

    - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
    {
        [UIView beginAnimations:@"View Flip" context:nil];
        [UIView setAnimationDuration:0.5f];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
        if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) {
            self.view = self.portraitView;
        } else {
            self.view = self.landscapeView;
        }
        [UIView commitAnimations];
        [self dismissModalViewControllerAnimated:NO];
    }
    

    Edit

    If you want to keep orientationChanged, then modify it as follows:

    -(void)orientationChanged:(NSNotification *)object{
        UIDeviceOrientation deviceOrientation = [[object object] orientation];
        if (deviceOrientation == UIInterfaceOrientationPortrait) {
            [UIView beginAnimations:@"View Flip" context:nil];
            [UIView setAnimationDuration:0.5f];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
            self.view = self.portraitView;
            [UIView commitAnimations];
            [self dismissModalViewControllerAnimated:NO];
        } else  if (deviceOrientation == UIInterfaceOrientationLandscapeLeft || deviceOrientation == UIInterfaceOrientationLandscapeRight) {
            [UIView beginAnimations:@"View Flip" context:nil];
            [UIView setAnimationDuration:0.5f];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
            self.view = self.landscapeView;
            [UIView commitAnimations];
            [self dismissModalViewControllerAnimated:NO];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Short Version: When I exit the App (home button), UIApplicationExitsOnSuspend is set to NO
I've got several functions in my php app that relay on calls to file_get_contents(),
I've installed the CakePHP core files in this folder: /home/iopener/webapps/cake_1.2.1.8004 I've got my app
My app got rejected for not setting the do not back up attribute to
My app just got approved for the apple store. I downloaded it an installed
I'm skinning scrollbar in my flex app and got one problem. This white square
I am developing an web app using Codeigniter. In this app I got a
I got an app running on my SQL Server that is starting to slow
I got a app who has Sonata User bundle and Sonata Admin bundle ,
I got an app with UITableView. Every cell has accessory. But i cant set

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.