Rotate Portrait Landscape with 2 XIB

I have 2 GUIs and 2 controllers 1 called landscapeguitontroller and the second one called highguicontroller.

Now, as a rule, I call highguicontroller, and when I turn my iphone, it detects this, and then it shows the landscape controller: Code:

    landscapeguicontroller *neu =[[landscapeguicontroller alloc] initWithNibName:nil bundle:nil];
    [self presentModalViewController:neu animated:YES];     
    [self dismissModalViewControllerAnimated:YES];

The problem is that then the animation pushes a new window from the outside of the iphone into the window.

In Landscapeguicontroller, I added to the following lines:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

when I want to return to calling highguicontroller i:

[self dismissModalViewControllerAnimated:YES];

that everything works, but only in the second animation do I see the correct "rotation animation". Do you have any suggestions?

So, a short description of the problem: in the animation from high to landscape, the landscape is inserted into the window BUT in animation 2. from landscape to high, the rotation looks like a real rotation ...

, 1. 2.

Ploetzeneder

+3
2

" , iphone ". modalTransitionStyle , , : typedef enum {  UIModalTransitionStyleCoverVertical = 0,  UIModalTransitionStyleFlipHorizontal,  UIModalTransitionStyleCrossDissolve, } UIModalTransitionStyle;

, , shouldRotate..., , , , . . Apple "AlternateViews".

, , . ( UApplications statusBarOrientation, , ).

+3

, , :

  • (highguicontroller)
  • (landscapeguicontroller) "" .

, highguicontroller - :

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
  return interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown;
}

2 ( ).

- :

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
  if(fromInterfaceOrientation == UIInterfaceOrientationPortrait) {
    [self presentModalViewController:landscapeguicontroller animated:YES];
  }
  else {
    [self dismissModalViewControllerAnimated:YES];
  }
}

, , .

, !

+1

Source: https://habr.com/ru/post/1720337/


All Articles