`
wonderzl
  • 浏览: 78900 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Push一个横屏页面

阅读更多
[[UIDevice currentDevice] 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旋转回去就可以了。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics