Question

Hi I have this piece of code...

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

and

- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{

  if(UIInterfaceOrientationIsPortrait(interfaceOrientation)){
    // WTF, this runs when I change to Landscape
  } else {
    // this runs when I change to Portrait??? shouldn't it be the contrary?
  }
}

as you see, the code is running in reverse, I mean, the part the should run when I change the device to portrait, the landscape part of the code runs and vice-versa.

WHen I turn the device, self.view rotates.

is this UIInterfaceOrientationIsPortrait testing how the interface is before the rotation or am I missing something?

thanks for any help.

Was it helpful?

Solution

Note that the method is named didRotateFromInterfaceOrientation, so naturally the interfaceOrientation parameter contains the old orientation, not the new one.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top