views:

1095

answers:

4

Hello, 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: Code:

  • (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

+1  A: 

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!

No Surprises
A: 

thanks :) nearly what i wanted, but i want that it directly rotates from portrait to landscape,...so no pushing any more. so in landscape you just see the landscape after the "turning animation" and in portrait you only see the highgui,..

Ploetzeneder
+2  A: 

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).

Shel
A: 

1)How do you put it on both Landscape and Portrait mode? I am Using the Navigation Based Application and in that the first view will have some words in row and I want display it with portrait mode(it is by default). From next view(SubView,SubSubView),I want to display in Landscape mode(not by default),because here the text will present.

2)And How can I get the spacing in the TextView?