ITeye博客

Push一个横屏页面

wonderzl · 2011-03-28 16:39 · iPhone开发 · 移动开发 · C · C++ · C# · Markdown

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


	[[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旋转回去就可以了。

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。