문제

i have got 2 GUIs and 2 Controllers 1 is called landscapeguicontroller and the second is called highguicontroller.

Now generally i call the highguicontroller, and when i rotate my iphone it detects that and then it shows the landscapeguicontroller: 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 the new window from the beyond side of the iphone up into the window.

In the Landscapeguicontroller,i have added to the the following lines:

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

when i want go back to the highguicontroller i call:

[self dismissModalViewControllerAnimated:YES];

that all works , but just in the second animation i see the correct "rotation animation". Have you got any suggestions?

So a short Problem description: in the 1. animation from high to landscape, the landscape is pushed into the window BUT in the 2. animation from landscape to high, the rotation looks like a real rotation...

i want the 1.animation look like the 2. animation

best regards Ploetzeneder

도움이 되었습니까?

해결책

To avoid "The Problem is that then the animation pushes the new window from the beyond side of the iphone up into the window.", try setting the view controller's modalTransitionStyle property to one of the following, whatever you prefer: typedef enum { UIModalTransitionStyleCoverVertical = 0, UIModalTransitionStyleFlipHorizontal, UIModalTransitionStyleCrossDissolve, } UIModalTransitionStyle;

Also, if you want to avoid the animated rotation, you can set your shouldRotate... method to disallow other orientations, but then set up to receive notifications when the device physically changes orientations, and present your modal viewcontroller when in the appropriate orientation for it. See Apple's "AlternateViews" sample code for an example of this.

The notifications reflect the physical orientation of the device, and you can receive them whether the interface is allowed to change or not. (You can look at the UIApplications's statusBarOrientation property to see what orientation the UI is in).

다른 팁

It sounds like you want the sequence to go like this:

  1. Physically rotate the device from portrait to landscape
  2. Animate the portrait view (highguicontroller) to landscape
  3. Push the landscape view (landscapeguicontroller) up from the new "bottom" of the screen

If that's right, you'll need to have something like the following in your highguicontroller implementation:

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

This will take care of step 2 (it will rotate the portrait view to landscape in either direction).

Then you'll want something like this:

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

That should present the landscape view after the rotation animation is complete and then dismiss it after the device is rotated back to portrait.

Hope that helps!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top