---
title: "Push一个横屏页面"
author: "wonderzl"
date: "2011-03-28T16:39:03Z"
tags: ["C", "C#", "C++"]
categories: ["移动开发"]
slug: "push"
draft: false
lastmod: "2011-03-28T16:42:14Z"
id: 977572
url: "https://wonderzl.iteye.com/blog/977572"
---

setOrientation: UIInterfaceOrientationLandscapeRight]，使用此方法可强制性的转为横屏，但在3.0以后此方法是私有方法。所以，好的方法是通过view的transform来转为横屏。


```Obj-c

	[[uiapplication sharedapplication] setStatusBarOrientation: UIInterfaceOrientationLandscapeRight animated: YES];
    CGFloat duration = [uiapplication sharedapplication].statusBarOrientationAnimationDuration;
	[uiview beginanimations:nil context:nil];
	[uiview setanimationduration:duration];
	self.navigationController.view.transform = CGAffineTransformIdentity;
    self.navigationController.view.transform = CGAffineTransformMakeRotation(M_PI*(90)/180.0);
    self.navigationController.view.bounds = CGRectMake(0, 0, 480, 320);
	[uiview commitanimations];

```


返回竖屏时，只需要在pop方法前，只需要把angle设为0.0旋转回去就可以了。