Adjusting a landscape screen I got the solution for the question asked here, but I don't like how the code is written.

This part of the code rotates the screen if it's in landscape and sets the size to match the screen. I don't like the if and the 7x else if. Can you suggest something more readable? Something like (appOrientation - fromInterfaceOrientation) == 2 than angle (M_PI / 2.0)? 

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{ 

    UIInterfaceOrientation appOrientation = [UIApplication sharedApplication].statusBarOrientation;
    float width = self.view.bounds.size.width;
    float height = self.view.bounds.size.height;
    //NSLog(@"width %3.0f, height: %3.0f", width, height);

//    UIInterfaceOrientationPortrait           = UIDeviceOrientationPortrait,
//    UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,
//    UIInterfaceOrientationLandscapeLeft      = UIDeviceOrientationLandscapeRight,
//    UIInterfaceOrientationLandscapeRight     = UIDeviceOrientationLandscapeLeft

    CGFloat angle = 0;

    // rotate from Portait
    if((fromInterfaceOrientation == UIInterfaceOrientationPortrait) &amp;&amp; (appOrientation == UIInterfaceOrientationLandscapeLeft)){
        angle = -(M_PI / 2.0);
    }
    else if((fromInterfaceOrientation == UIInterfaceOrientationPortrait) &amp;&amp; (appOrientation == UIInterfaceOrientationLandscapeRight)){
        angle = (M_PI / 2.0);
    }    
    // rotate from PortraitUpsideDown
    else if((fromInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) &amp;&amp; (appOrientation == UIInterfaceOrientationLandscapeLeft)){
        angle = (M_PI / 2.0);
    }
    else if((fromInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) &amp;&amp; (appOrientation == UIInterfaceOrientationLandscapeRight)){
        angle = -(M_PI / 2.0);
    }


    //rotate from Landscape:
    else if((fromInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) &amp;&amp; (appOrientation == UIInterfaceOrientationPortrait)){
        // search for exactly the inverse...
    }
    // must be something more elgant code


    CGAffineTransform transform = self.view.transform;
    transform = CGAffineTransformRotate(transform, angle);
    self.view.transform = transform;            

    [self.view setBounds:CGRectMake(0, 0, height, width)];
I think that you can rewrite the code in a more OO way, with the help of an NSDictionary and setting up a sort of command pattern.

You can store a sum of the two enumerator value as a key of the Dictionary in this way : 

NSDictionary *dicAngles = [[NSDictionary alloc] initWithObjectsAndKeys: 
        (UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft), -(M_PI / 2.0),     (UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeRight), (M_PI / 2.0), 
(UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft), (M_PI / 2.0), 
(UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeRight), -(M_PI / 2.0),
 nil];


Once you have the dictionary you can avoid the if - else control flow in this way : 

 CGFloat angle = 0;
 //Retrieve the angle from the dictionary 
 angle = [dicAngles objectForKey: ( fromInterfaceOrientation + appOrientation )];


It is only an example and not tested, but could be a more elegant solution i think ...