orientation in a UIView add to a UIWindow

UIView *customView;
UIWindow *window = [[[UIApplication sharedApplication] keyWindow] addSubview:customView];

in the ViewController:shouldAutorotateToInterfaceOrientation

  switch (interfaceOrientation) {

 

        case UIInterfaceOrientationLandscapeLeft:

            customView.transform = CGAffineTransformMakeRotation(-M_PI /2.0);

            break;

        case UIInterfaceOrientationLandscapeRight:

            customView.transform = CGAffineTransformMakeRotation(M_PI /2.0);

            break;

        case UIInterfaceOrientationPortraitUpsideDown:

            customView.transform = CGAffineTransformMakeRotation(M_PI);

            break;

        default:

            customView.transform = CGAffineTransformMakeRotation(0.0);

            break;

    }

    return YES;

reference:

http://stackoverflow.com/questions/2508630/orientation-in-a-uiview-added-to-a-uiwindow

http://stackoverflow.com/questions/3353571/custom-uiwindow-orientation

posted @ 2012-06-04 19:22  Lawerence  阅读(459)  评论(0编辑  收藏  举报